Jump to content
holyfield

Pattern of MLB (Main Logic Board)

575 posts in this topic

Recommended Posts

If anyone wants take a look:

/* This file has been generated by the Hex-Rays decompiler.
   Copyright (c) 2007-2014 Hex-Rays <info@hex-rays.com>

   Detected compiler: Unknown
*/

#include <defs.h>


//-------------------------------------------------------------------------
// Function declarations

int __cdecl sub_1641(int a1, int a2);
int __cdecl sub_1849(int a1, int a2);
signed int __cdecl sub_1BAC(int a1);
signed int sub_23C4();
signed int sub_2D22();
int __cdecl sub_2F3A(int a1);
int __cdecl sub_30A3(int a1);
int __cdecl sub_31EB(int a1);
int __cdecl sub_3392(int a1, int a2, int a3, unsigned int a4);
int __cdecl sub_3E75(int a1);
bool __cdecl sub_412E(int a1);
signed int __cdecl sub_48DC(int a1);
int __cdecl sub_4E73(int a1, int a2);
int __cdecl sub_4EA0(int a1);
int __cdecl sub_4EC6(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8);
int __cdecl sub_4F1D(int a1, int a2);
int __cdecl sub_4F4A(int a1, int a2);
int __cdecl sub_4F77(int a1);
int __cdecl sub_4F9D(int a1, int a2, int a3, int a4, __int16 a5, int a6, __int16 a7);
int __cdecl sub_4FF8(int a1);
int __cdecl sub_51CE(int a1, int a2, int a3, int a4);
int __cdecl sub_54CB(int a1, int a2);
int sub_59A8(); // weak
int sub_5F32(); // weak
int __cdecl sub_5FAF(int a1, int a2, int a3, int a4, char a5);
int __cdecl sub_61E8(int a1, int a2, int a3, int a4, int a5, int a6);
int __cdecl sub_6234(int a1, int a2, int a3, int a4);
int __cdecl sub_64C8(char a1, int a2, int a3, int a4, int a5);
int __cdecl sub_6511(char a1, int a2, int a3, int a4, unsigned __int8 a5);
int sub_6561();
int __cdecl sub_683B(int a1, int a2, int a3);
int __cdecl sub_6893(int a1, int a2, int a3);
int __cdecl sub_6987(unsigned __int8 a1, int a2);
int __cdecl sub_6BCE(int a1, int a2);
int __cdecl sub_6C92(int a1, int a2);
int __cdecl sub_6CC2(int a1, unsigned __int8 a2);
int __cdecl sub_6D34(int a1, int a2);
int __cdecl sub_6EC6(int a1, int a2, int a3);
int __cdecl sub_6EFD(int a1, int a2, char a3);
int __cdecl sub_6F24(int a1, int a2);
int __cdecl sub_6F8B(int a1, int a2);
int __cdecl sub_7034(int a1);
int sub_7AE2(); // weak
int sub_7B34();
int __cdecl sub_7C00(int a1, int a2, unsigned int a3);
int __cdecl sub_7E67(int a1, char a2, int a3);
signed int __cdecl sub_80C5(int a1, int a2);
signed int __cdecl sub_8252(int a1);
signed int sub_830D();
signed int __cdecl sub_849A(int a1, int a2, int a3, char a4);
signed int __cdecl sub_8AD4(int a1, int a2, int a3);
int __cdecl sub_8CBD(int a1, unsigned __int8 a2);
int __cdecl sub_8D02(int a1, unsigned __int8 a2);
// void __usercall sub_92D9(int a1@<ebp>);
int __cdecl sub_9DAC(int a1);
int __cdecl sub_9E8A(int a1);
int __cdecl sub_9F6C(int a1, int a2);
int __cdecl sub_A03E(int a1, int a2);
int __cdecl sub_A1CB(int a1, int a2);
int __cdecl sub_A2BD(int a1, int a2);
signed int __cdecl sub_A539(int a1, int a2, int a3, int a4);
int __cdecl sub_A5CB(int a1, int a2, int a3, int a4);
int __cdecl sub_A634(int a1, int a2, int a3, int a4, int a5, int a6, int a7);
int sub_A762(); // weak
int __cdecl sub_A82A(int a1);
int sub_A874(); // weak
int __cdecl sub_A8A4(int a1, int a2);
int __cdecl sub_A90D(int a1, int a2);
int __cdecl sub_AA03(int a1);
int __cdecl sub_AA70(int a1, unsigned int a2, int a3, unsigned int *a4);
int __cdecl sub_B3BF(int a1, int a2, int a3, char a4);
int __cdecl sub_B563(int a1, char a2);
signed int __cdecl sub_B631(int a1, int a2);
int __cdecl sub_B65D(int a1, int a2);
int __cdecl sub_B680(int a1);
int __cdecl sub_B694(unsigned __int16 *a1, int a2);
int __cdecl sub_B708(int a1);
int __cdecl sub_B71B(int a1, int a2);
int sub_B7E8(); // weak
int __cdecl sub_B8EA(int a1);
int __cdecl sub_BACB(int a1, int a2);
int __cdecl sub_BC21(int a1, unsigned int a2, unsigned int a3, char a4, unsigned int a5);
int __cdecl sub_BCF9(int a1, int a2, int a3, unsigned int a4, unsigned int a5);
unsigned __int64 __cdecl sub_BEC7(unsigned __int64 a1, char a2);
unsigned __int64 __cdecl sub_BEE3(unsigned __int64 a1, unsigned int a2, int a3);
unsigned __int64 __cdecl sub_BFD0(unsigned __int64 a1, unsigned int a2, unsigned int a3);
int __cdecl sub_C120(unsigned __int64 a1, __int64 a2);
int __fastcall sub_12590(int a1, int a2);
// int __usercall sub_14282@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebp>);
int *__fastcall sub_14DDA(int a1);
bool __fastcall sub_1510C(int a1);
// int __usercall sub_1590E@<eax>(int a1@<ecx>, unsigned int a2@<ebx>, int a3@<edi>, int a4@<esi>);
int sub_15E60();
int sub_15E87();
int __fastcall sub_15EA6(int a1, int (__fastcall *a2)(_DWORD));
int sub_15F09();
int sub_15F2E();
int sub_15F58();
int __fastcall sub_15F7A(int a1);
int sub_15FD3();
int __fastcall sub_161FA(int a1);
unsigned int __fastcall sub_164EA(int a1, int a2);
// void __usercall sub_16F2C(char a1@<al>, int a2, int a3, int a4, int a5, int a6, int a7, int a8);
int __fastcall sub_173E1(int a1);
int __fastcall sub_17431(char *a1);
int __fastcall sub_176AC(char a1);
int __fastcall sub_176FE(char a1);
int sub_17755();
// int __usercall sub_179D7@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4, int a5, int a6, __int64 a7);
// int __usercall sub_17A4E@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4, int a5, int a6, __int64 a7);
int __fastcall sub_17B43(unsigned __int8 a1);
int __fastcall sub_17D51(int a1, int a2);
int sub_17E2E();
int __fastcall sub_17E56(int a1, char a2);
int __fastcall sub_17EEE(int a1, int a2);
int __fastcall sub_180A8(int a1);
// void __usercall sub_180DE(char a1@<al>, int a2, int a3, int a4);
int sub_181AF();
int __fastcall sub_1820F(int a1, int a2);
int __fastcall sub_182C1(int a1);
int sub_19028();
// int __usercall sub_190F8@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, unsigned int _EBX@<ebx>);
// int __usercall sub_1937A@<eax>(int a1@<eax>, char a2@<dl>, int a3@<ecx>);
signed int __fastcall sub_19600(int a1, int a2);
int __fastcall sub_1978E(int a1);
signed int sub_1984E();
// signed int __usercall sub_199DA@<eax>(int a1@<eax>, int a2@<edx>, int (__fastcall *a3)(_DWORD)@<ecx>, unsigned int a4@<ebx>, int a5@<edi>, int a6@<esi>);
// int __usercall sub_1A04A@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4, int a5, int a6, int a7, int a8, int a9, int a10);
int __fastcall sub_1A263(int a1);
int __fastcall sub_1A2A9(int a1);
int __fastcall sub_1B38D(int a1);
int __fastcall sub_1B44F(int a1);
int __fastcall sub_1B544(int a1, int a2);
int __fastcall sub_1B60F(int a1, int a2);
// char *__usercall sub_1B7A2@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebx>, int a5@<ebp>, int a6@<edi>, int a7@<esi>);
int __fastcall sub_1B8A5(int a1, int a2);
// int __usercall sub_1BBDD@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebx>, int a5@<ebp>, int a6@<edi>, int a7@<esi>);
// int __usercall sub_1BC39@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebx>, int a5@<ebp>, int a6@<edi>, int a7@<esi>);
int __fastcall sub_1BE85(int a1);
int __fastcall sub_1BEED(int a1);
// int __usercall sub_1BFD6@<eax>(int a1@<ecx>, int a2@<ebx>, int a3@<ebp>, int a4@<edi>, int a5@<esi>);
// void __usercall sub_1CA08(char a1@<al>);
// void __usercall sub_1CCFC(char a1@<al>, int a2@<edx>, int a3@<ecx>);
int __fastcall sub_1CED1(int a1, int a2);
signed int __fastcall sub_1CEF1(int a1);
int __fastcall sub_1CF05(int a1, int a2);
signed int __fastcall sub_1CF6E(int a1);
int __fastcall sub_1CF81(int a1, int a2);
signed int __fastcall sub_1D14A(int a1);
int __fastcall sub_1D32B(int a1, int a2);

//-------------------------------------------------------------------------
// Data declarations

_UNKNOWN unk_0; // weak
_UNKNOWN loc_1; // weak
_UNKNOWN loc_4; // weak
_UNKNOWN loc_7; // weak
char byte_9[3] = { '\0', '\0', '\0' }; // weak
_UNKNOWN unk_C; // weak
int (*off_15)[6] = &dword_10C; // weak
_UNKNOWN unk_20; // weak
__int16 *off_29 = &word_146; // weak
void *off_37 = (void *)0x400; // weak
_UNKNOWN unk_3B; // weak
_UNKNOWN unk_3C; // weak
_UNKNOWN unk_40; // weak
_UNKNOWN unk_44; // weak
_UNKNOWN unk_48; // weak
int dword_4C[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
int dword_74[13] =
{
  3439965184,
  1275181089,
  1750344141,
  1881174889,
  1919381362,
  1663069537,
  1869508193,
  1700929652,
  1853190688,
  544106784,
  542330692,
  1701080941,
  168627502
}; // weak
int dword_124[8] = { 16, 0, 0, 0, 0, 0, 0, 0 }; // weak
int dword_158[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
_UNKNOWN unk_230; // weak
int dword_244[4] = { 3758096416, 1952539694, 97, 0 }; // weak
_UNKNOWN loc_5FE; // weak
char *off_1878 = &byte_AB; // weak
_UNKNOWN loc_4EA7; // weak
_UNKNOWN loc_570E; // weak
_UNKNOWN loc_5794; // weak
_UNKNOWN loc_5E0D; // weak
_UNKNOWN loc_5EF6; // weak
_UNKNOWN loc_6015; // weak
_UNKNOWN loc_6162; // weak
_UNKNOWN loc_82C0; // weak
_UNKNOWN loc_82CC; // weak
_UNKNOWN loc_82E8; // weak
_UNKNOWN loc_8304; // weak
_UNKNOWN loc_835C; // weak
_UNKNOWN loc_8399; // weak
_UNKNOWN loc_83A9; // weak
_UNKNOWN loc_83BD; // weak
_UNKNOWN loc_88D2; // weak
_UNKNOWN loc_89BE; // weak
_UNKNOWN loc_8A25; // weak
_UNKNOWN loc_8C5D; // weak
_UNKNOWN loc_8C6F; // weak
_UNKNOWN loc_8C77; // weak
_UNKNOWN loc_8FEA; // weak
_UNKNOWN loc_9002; // weak
_UNKNOWN loc_9019; // weak
_UNKNOWN loc_90A3; // weak
_UNKNOWN loc_90AB; // weak
_UNKNOWN loc_923D; // weak
char algn_9429[3] = { '\x0F', '\x1F', '\0' }; // weak
_UNKNOWN loc_94FE; // weak
_UNKNOWN loc_953F; // weak
_UNKNOWN loc_970F; // weak
_UNKNOWN loc_97BA; // weak
_UNKNOWN loc_A6A0; // weak
_UNKNOWN loc_A6EC; // weak
_UNKNOWN loc_A7FD; // weak
_UNKNOWN loc_A84D; // weak
_UNKNOWN loc_A8C6; // weak
_UNKNOWN loc_AAAE; // weak
_UNKNOWN loc_AAC3; // weak
_UNKNOWN loc_AAE5; // weak
void *off_AB14[77] =
{
  &off_1E5,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  (void *)0x209,
  (void *)0x1D9,
  (void *)0x1F1,
  (void *)0x1CD,
  &off_254,
  &off_254,
  &unk_21D,
  &unk_224,
  &unk_224,
  &unk_224,
  &unk_224,
  &unk_224,
  &unk_224,
  &unk_224,
  &unk_224,
  &unk_224,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  (void *)0x1FD,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  &off_254,
  (void *)0x1FD
}; // weak
_UNKNOWN loc_AC4F; // weak
_UNKNOWN loc_ACB4; // weak
_UNKNOWN loc_ACE1; // weak
void *off_ACEC[84] =
{
  (void *)0x8E3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x4E9,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  &loc_3C1,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  &loc_567,
  (void *)0x8F3,
  (void *)0x5E2,
  (void *)0x459,
  (void *)0x8F3,
  (void *)0x8F3,
  &loc_5FE,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x6EA,
  (void *)0x4E9,
  (void *)0x68D,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x8F3,
  (void *)0x3CF
}; // weak
_UNKNOWN loc_AE63; // weak
_UNKNOWN loc_AE69; // weak
_UNKNOWN loc_AEC7; // weak
_UNKNOWN loc_AF6D; // weak
_UNKNOWN loc_AFA7; // weak
_UNKNOWN loc_AFCF; // weak
_UNKNOWN loc_B039; // weak
_UNKNOWN loc_B0A3; // weak
_UNKNOWN loc_B103; // weak
_UNKNOWN loc_B297; // weak
_UNKNOWN loc_B301; // weak
_UNKNOWN loc_B36E; // weak
_UNKNOWN loc_B3D9; // weak
_UNKNOWN loc_B410; // weak
_UNKNOWN loc_B477; // weak
_UNKNOWN loc_B640; // weak
_UNKNOWN loc_B6A2; // weak
_UNKNOWN loc_B6D2; // weak
_UNKNOWN loc_B731; // weak
_UNKNOWN loc_B7EB; // weak
_UNKNOWN loc_B837; // weak
_UNKNOWN loc_B886; // weak
int dword_C3B2 = 0; // weak
int dword_C3B8[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
char byte_C3F9[3] = { '\0', '\0', '\0' }; // weak
__int16 word_C3FE = 0; // weak
int dword_C404[14] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
__int16 word_C43E = 0; // weak
int dword_C444[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
int dword_C474[6] = { 0, 0, 0, 0, 0, 0 }; // weak
int dword_C6A4[111] =
{
  670309,
  1681010725,
  540876858,
  807761968,
  807761970,
  622884914,
  628634160,
  544748080,
  2016555045,
  2016555045,
  842016032,
  842016120,
  2680,
  1953719636,
  1887007776,
  1868963941,
  1634476146,
  1176532083,
  1914721347,
  1998614133,
  622883681,
  173551920,
  1414743296,
  1280114783,
  21058,
  1330795077,
  1397039186,
  1701519444,
  2019893369,
  1937011561,
  1953849888,
  544434464,
  544501614,
  561276275,
  10,
  1197425744,
  1631876197,
  540696948,
  1380076621,
  622869792,
  1696607332,
  540701298,
  1814394928,
  673216620,
  1814394928,
  170489964,
  1112296704,
  1701519442,
  1936269433,
  1953459744,
  1952805664,
  10,
  1819635523,
  1948741220,
  1952802592,
  1112296736,
  1701519442,
  1953702009,
  1937077345,
  1951606816,
  1937077345,
  628633661,
  695744560,
  1280114698,
  1797280322,
  1763735909,
  1702043763,
  1869881460,
  667680,
  1380076621,
  2036689696,
  544434464,
  544499059,
  824209268,
  1160183818,
  660558931,
  2036689696,
  544434464,
  544499059,
  824209268,
  10,
  1414743335,
  1797269343,
  1763735909,
  1869488243,
  1702043764,
  1919885428,
  1952805664,
  544175136,
  2608,
  1330795077,
  1280122962,
  1699881026,
  1667329136,
  1109419109,
  1025537129,
  744760608,
  1414743328,
  1953055264,
  622869792,
  2660,
  1330795077,
  1397039186,
  1701519444,
  1634214009,
  1330520179,
  1700929620,
  1663069797,
  1918985580,
  169960549,
  0
}; // weak
char byte_CB71[3] = { '0', '0', '0' }; // weak
char byte_CB79[3] = { '0', '2', 'x' }; // weak
int dword_CB84[4] = { 2112120, 536879136, 2105376, 1769104723 }; // weak
char byte_CBFB = '\0'; // weak
int dword_CCC4[5] = { 1953460066, 1952542765, 1931804776, 7546173, 1953396050 }; // weak
_UNKNOWN unk_CCDB; // weak
int dword_CD14[254] =
{
  1684107116,
  1986622020,
  690516581,
  10,
  1869377109,
  1852400737,
  1919164519,
  1919252073,
  1936467232,
  10,
  1869377109,
  1917084769,
  1919252073,
  1663052072,
  1819307375,
  1684370533,
  1953703968,
  1937077345,
  2015699002,
  1006635561,
  1819047278,
  1920234272,
  1046965865,
  1668633344,
  1936942435,
  1634683904,
  1917132900,
  7499634,
  1635151433,
  543451500,
  1634885968,
  1702126957,
  1851064434,
  1886418291,
  1702130287,
  1631715428,
  1967267940,
  1919247974,
  2053722912,
  1967259749,
  1919247974,
  1869567008,
  1634554656,
  1308650604,
  1377858671,
  2036621669,
  1986348032,
  543515497,
  1869771333,
  1918304370,
  543519849,
  1953460816,
  1702126437,
  1968111716,
  1718558836,
  1936020000,
  1668445551,
  1442870117,
  1836412015,
  1866670181,
  1886745202,
  1867907188,
  1701672300,
  1819624992,
  1867382892,
  1684360480,
  1291870569,
  1634296933,
  1634231072,
  1684367214,
  1953451520,
  1970226720,
  1090544750,
  1936024419,
  1698963571,
  1684367726,
  544165376,
  1886610770,
  1702063727,
  544165376,
  1886413165,
  6778473,
  1701669204,
  1953853216,
  1953451520,
  1635021600,
  1684370546,
  1919697152,
  2036621669,
  1635021600,
  1684370546,
  1868710144,
  1684370546,
  1296255232,
  1917132880,
  7499634,
  1347700308,
  1920091424,
  1342206575,
  1869901682,
  543977315,
  1869771333,
  1633091698,
  1852403314,
  1851072615,
  2003791467,
  1816600686,
  6844537,
  1852989783,
  543649385,
  1701602628,
  1176528244,
  1970039137,
  1459643762,
  1768845921,
  1461741422,
  1702127986,
  1767982624,
  1701999980,
  1918981888,
  1735289198,
  1718960672,
  544367974,
  544173908,
  1818324307,
  108,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
}; // weak
__int16 aRifyIctWasRunA[28] =
{
  114,
  105,
  102,
  121,
  32,
  73,
  67,
  84,
  32,
  87,
  97,
  115,
  32,
  82,
  117,
  110,
  32,
  65,
  110,
  100,
  32,
  80,
  97,
  115,
  115,
  101,
  100,
  0
}; // weak
__int16 aRifyIctWasRu_0[44] =
{
  114,
  105,
  102,
  121,
  32,
  73,
  67,
  84,
  32,
  119,
  97,
  115,
  32,
  114,
  117,
  110,
  32,
  97,
  110,
  100,
  32,
  108,
  97,
  115,
  116,
  32,
  105,
  116,
  101,
  114,
  97,
  116,
  105,
  111,
  110,
  32,
  112,
  97,
  115,
  115,
  101,
  100,
  46,
  0
}; // weak
int dword_D1AC[8] = { 2621440, 7077987, 7536737, 3997811, 5046306, 4325452, 2687010, 0 }; // weak
__int16 aRifyEstBitSetT[22] =
{
  114,
  105,
  102,
  121,
  32,
  69,
  83,
  84,
  32,
  66,
  105,
  116,
  32,
  83,
  101,
  116,
  32,
  84,
  101,
  115,
  116,
  0
}; // weak
__int16 aRifyTheExtende[43] =
{
  114,
  105,
  102,
  121,
  32,
  84,
  104,
  101,
  32,
  69,
  120,
  116,
  101,
  110,
  100,
  101,
  100,
  32,
  83,
  101,
  114,
  118,
  105,
  99,
  101,
  32,
  84,
  101,
  115,
  116,
  32,
  66,
  105,
  116,
  32,
  105,
  115,
  32,
  115,
  101,
  116,
  46,
  0
}; // weak
_UNKNOWN unk_DD00; // weak
_UNKNOWN off_DD50; // weak
_UNKNOWN unk_E01C; // weak
__int16 aSetmlbreplaced[15] = { 83, 101, 116, 77, 76, 66, 82, 101, 112, 108, 97, 99, 101, 100, 0 }; // weak
int dword_E045 = 1107315712; // weak
__int16 aGetrtcramsize[14] = { 71, 101, 116, 82, 84, 67, 82, 97, 109, 83, 105, 122, 101, 0 }; // weak
_UNKNOWN unk_E06C; // weak
__int16 aNdleprotocolEr[26] =
{
  110,
  100,
  108,
  101,
  80,
  114,
  111,
  116,
  111,
  99,
  111,
  108,
  32,
  69,
  114,
  114,
  111,
  114,
  58,
  32,
  48,
  120,
  37,
  120,
  10,
  0
}; // weak
__int16 a16450Compatabl[30] =
{
  49,
  54,
  52,
  53,
  48,
  32,
  99,
  111,
  109,
  112,
  97,
  116,
  97,
  98,
  108,
  101,
  32,
  83,
  101,
  114,
  105,
  97,
  108,
  32,
  80,
  111,
  114,
  116,
  10,
  0
}; // weak
__int16 a16550Compatabl[30] =
{
  49,
  54,
  53,
  53,
  48,
  32,
  99,
  111,
  109,
  112,
  97,
  116,
  97,
  98,
  108,
  101,
  32,
  83,
  101,
  114,
  105,
  97,
  108,
  32,
  80,
  111,
  114,
  116,
  10,
  0
}; // weak
__int16 aDirectionalPar[28] =
{
  45,
  100,
  105,
  114,
  101,
  99,
  116,
  105,
  111,
  110,
  97,
  108,
  32,
  112,
  97,
  114,
  97,
  108,
  108,
  101,
  108,
  32,
  112,
  111,
  114,
  116,
  10,
  0
}; // weak
__int16 aBaseSystemPeri[29] =
{
  32,
  32,
  32,
  66,
  97,
  115,
  101,
  32,
  83,
  121,
  115,
  116,
  101,
  109,
  32,
  80,
  101,
  114,
  105,
  112,
  104,
  101,
  114,
  97,
  108,
  115,
  44,
  32,
  0
}; // weak
__int16 aNeric8259Progr[38] =
{
  110,
  101,
  114,
  105,
  99,
  32,
  56,
  50,
  53,
  57,
  32,
  80,
  114,
  111,
  103,
  114,
  97,
  109,
  109,
  98,
  108,
  101,
  32,
  73,
  110,
  116,
  101,
  114,
  114,
  117,
  112,
  116,
  32,
  67,
  111,
  110,
  116,
  114
}; // weak
__int16 aOgrammableInte[33] =
{
  111,
  103,
  114,
  97,
  109,
  109,
  97,
  98,
  108,
  101,
  32,
  73,
  110,
  116,
  101,
  114,
  114,
  117,
  112,
  116,
  32,
  67,
  111,
  110,
  116,
  114,
  111,
  108,
  108,
  101,
  114,
  10,
  0
}; // weak
_UNKNOWN unk_EAE6; // weak
__int16 aNeric8237DmaCo[27] =
{
  110,
  101,
  114,
  105,
  99,
  32,
  56,
  50,
  51,
  55,
  32,
  68,
  77,
  65,
  32,
  99,
  111,
  110,
  116,
  114,
  111,
  108,
  108,
  101,
  114,
  10,
  0
}; // weak
__int16 aNtium[7] = { 110, 116, 105, 117, 109, 10, 0 }; // weak
_UNKNOWN unk_EDBB; // weak
__int16 aSerialBusContr[27] =
{
  32,
  32,
  32,
  83,
  101,
  114,
  105,
  97,
  108,
  32,
  66,
  117,
  115,
  32,
  67,
  111,
  110,
  116,
  114,
  111,
  108,
  108,
  101,
  114,
  44,
  32,
  0
}; // weak
__int16 aRewireIeee1394[19] =
{
  114,
  101,
  119,
  105,
  114,
  101,
  40,
  73,
  69,
  69,
  69,
  32,
  49,
  51,
  57,
  52,
  41,
  10,
  0
}; // weak
__int16 a8x04x04x02x02x[47] =
{
  56,
  120,
  45,
  37,
  48,
  52,
  120,
  45,
  37,
  48,
  52,
  120,
  45,
  37,
  48,
  50,
  120,
  37,
  48,
  50,
  120,
  45,
  37,
  48,
  50,
  120,
  37,
  48,
  50,
  120,
  37,
  48,
  50,
  120,
  37,
  48,
  50,
  120,
  37,
  48,
  50,
  120,
  37,
  48,
  50,
  120,
  0
}; // weak
int dword_EF40[20] = { 2424832, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
int dword_EF90[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
int dword_EFB4 = 0; // weak
int dword_EFBC[4] = { 0, 0, 0, 0 }; // weak
int dword_EFCC = 0; // weak
int dword_EFD0[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
int dword_F010[48] =
{
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
}; // weak
int dword_F0D0[32] =
{
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
}; // weak
int dword_F150[21] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // weak
_UNKNOWN unk_F6B8; // weak
int dword_FA94[104] =
{
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
}; // weak
int dword_FC3C[2] = { 0, 0 }; // weak
int dword_FC44[2] = { 0, 0 }; // weak
int dword_FC74[3] = { 0, 0, 0 }; // weak
int dword_10000[640] =
{
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
}; // weak
_UNKNOWN unk_10C3E; // weak


//----- (00001641) --------------------------------------------------------
int __cdecl sub_1641(int a1, int a2)
{
  int result; // eax@1

  _EAX = a1;
  __asm { cpuid }
  *(_DWORD *)a2 = _EAX;
  *(_DWORD *)(a2 + 4) = _EBX;
  result = a2 + 8;
  *(_DWORD *)(a2 + 8) = _ECX;
  *(_DWORD *)(a2 + 12) = _EDX;
  return result;
}

//----- (00001849) --------------------------------------------------------
int __cdecl sub_1849(int a1, int a2)
{
  int v3; // [sp+28h] [bp-10h]@3
  int v4; // [sp+2Ch] [bp-Ch]@3

  if ( (unsigned int)a2 <= 7 )
    JUMPOUT(__CS__, (&off_1878)[4 * a2] + 6229);
  (*(void (__cdecl **)(int, signed int, int *))(a1 + 12))(a1, 1296843359, &v3);
  if ( v4 >= 0 )
    sub_61E8(1296843359, v3, a2, v4, 0, 0);
  else
    sub_6234(1296843359, v3, a2, v4);
  return v4;
}
// 1878: using guessed type char *off_1878;

//----- (00001BAC) --------------------------------------------------------
signed int __cdecl sub_1BAC(int a1)
{
  char v1; // ST14_1@9
  int v2; // ST34_4@10
  int v3; // ST30_4@10
  int v4; // ST2C_4@10
  int v5; // ST28_4@10
  int v6; // ST24_4@10
  int v7; // ST20_4@10
  int v8; // ST1C_4@10
  int v9; // ST18_4@10
  unsigned __int64 v10; // rax@17
  signed int v12; // [sp+5Ch] [bp-8Ch]@3
  unsigned __int64 v13; // [sp+78h] [bp-70h]@5
  char v14[32]; // [sp+86h] [bp-62h]@7
  unsigned __int16 v15; // [sp+A6h] [bp-42h]@1
  char v16; // [sp+A9h] [bp-3Fh]@1
  __int16 v17; // [sp+AAh] [bp-3Eh]@1
  char v18; // [sp+ACh] [bp-3Ch]@2
  int v19; // [sp+BCh] [bp-2Ch]@1
  int v20; // [sp+C0h] [bp-28h]@1
  int v21; // [sp+C4h] [bp-24h]@1
  char v22; // [sp+CBh] [bp-1Dh]@1
  unsigned int i; // [sp+CCh] [bp-1Ch]@9

  v20 = 0;
  v22 = 2;
  (*(void (__cdecl **)(int, signed int, int *))(a1 + 12))(a1, 1296843359, &v19);
  v17 = 2;
  v21 = sub_64C8(v22, (int)&dword_C3B2, (int)&v15, (int)&v17, (int)&v16);
  if ( v21 >= 0 )
  {
    v17 = 8;
    v21 = sub_64C8(v22, (int)&word_C3FE, (int)&v13, (int)&v17, (int)&v16);
    if ( v21 >= 0 )
    {
      v17 = 32;
      v21 = sub_64C8(v22, (int)&word_C43E, (int)v14, (int)&v17, (int)&v16);
      if ( v21 >= 0 )
      {
        sub_5FAF(1296843359, 1480868423, v19, (int)dword_C474, v15);
        sub_5FAF(1296843359, 1480868423, v19, (int)"cate the SmcIo Protocol\n", v1);
        for ( i = 0; i <= 0x1F; i += 8 )
        {
          v2 = (unsigned __int8)v14[i + 7];
          v3 = (unsigned __int8)v14[i + 6];
          v4 = (unsigned __int8)v14[i + 5];
          v5 = (unsigned __int8)v14[i + 4];
          v6 = (unsigned __int8)v14[i + 3];
          v7 = (unsigned __int8)v14[i + 2];
          v8 = (unsigned __int8)v14[i + 1];
          v9 = (unsigned __int8)v14[i];
          sub_5FAF(1296843359, 1480868423, v19, (int)"Io Protocol\n", i);
        }
        if ( v15 > 0x40u )
          v15 = 64;
        if ( v15 & 1 )
          sub_5FAF(1296843359, 1481856065, v19, (int)"dge\n", (unsigned __int8)v14[(v15 - 1) / 2] >> 4);
        else
          sub_5FAF(1296843359, 1481856065, v19, (int)"dge\n", v14[(v15 - 1) / 2] & 0xF);
        v10 = v13 >> ((64 - v15) & 0x1F);
        if ( (64 - (_BYTE)v15) & 0x20 )
          LOBYTE(v10) = v13 >> ((64 - v15) & 0x1F) >> 32;
        if ( v10 & 1 )
          v20 = 0;
        else
          v20 = 1073741846;
        v12 = v20;
      }
      else
      {
        sub_5FAF(1296843359, 1480938066, v19, (int)dword_C444, v21);
        v12 = 1073741826;
      }
    }
    else
    {
      sub_5FAF(1296843359, 1480938066, v19, (int)dword_C404, v21);
      v12 = 1073741826;
    }
  }
  else
  {
    sub_5FAF(1296843359, 1481856065, v19, (int)dword_C3B8, v21);
    v17 = 16;
    v21 = sub_64C8(v22, (int)byte_C3F9, (int)&v18, (int)&v17, (int)&v16);
    if ( v21 >= 0 )
      v12 = v20;
    else
      v12 = 1073741826;
  }
  return v12;
}
// C3B2: using guessed type int dword_C3B2;
// C3B8: using guessed type int dword_C3B8[16];
// C3FE: using guessed type __int16 word_C3FE;
// C404: using guessed type int dword_C404[14];
// C43E: using guessed type __int16 word_C43E;
// C444: using guessed type int dword_C444[12];
// C474: using guessed type int dword_C474[6];
// 1BAC: using guessed type char var_62[32];

//----- (000023C4) --------------------------------------------------------
signed int sub_23C4()
{
  int v2; // [sp+30h] [bp-38h]@1
  char v3; // [sp+36h] [bp-32h]@1
  __int16 v4; // [sp+46h] [bp-22h]@2
  char v5; // [sp+48h] [bp-20h]@2
  char v6; // [sp+49h] [bp-1Fh]@2
  char v7; // [sp+4Ah] [bp-1Eh]@2
  int v8; // [sp+58h] [bp-10h]@1
  char v9; // [sp+5Eh] [bp-Ah]@1
  unsigned __int8 v10; // [sp+5Fh] [bp-9h]@2

  v8 = 0;
  v9 = 2;
  v2 = 16;
  v8 = (*(int (__cdecl **)(_DWORD, int, _DWORD, int *, char *))(unk_0 + 48))(L"ailed", dword_FC3C[0], 0, &v2, &v3);
  if ( v8 < 0 )
  {
    if ( v8 == -2147483634 )
      return -2147483622;
    return v8;
  }
  v5 = 1;
  v6 = -2;
  v7 = 0;
  v4 = 2;
  v8 = sub_6511(v9, (int)byte_C3F9, (int)&v5, (int)&v4, v10);
  if ( v8 >= 0 )
  {
    v8 = sub_6561();
    if ( v8 < 0 )
      return v8;
    return v8;
  }
  return v8;
}
// DCAC: using guessed type __int16 aAiled[6];
// FC3C: using guessed type int dword_FC3C[2];

//----- (00002D22) --------------------------------------------------------
signed int sub_2D22()
{
  int v0; // ST24_4@23
  signed int v2; // [sp+Ch] [bp-2Ch]@3
  __int16 v3; // [sp+1Eh] [bp-1Ah]@4
  __int16 v4; // [sp+1Eh] [bp-1Ah]@11
  __int16 v5; // [sp+1Eh] [bp-1Ah]@18
  __int16 v6; // [sp+1Eh] [bp-1Ah]@25
  int v7; // [sp+24h] [bp-14h]@1
  unsigned int i; // [sp+28h] [bp-10h]@4
  unsigned int j; // [sp+28h] [bp-10h]@11
  unsigned int k; // [sp+28h] [bp-10h]@18
  unsigned int l; // [sp+28h] [bp-10h]@25
  signed int v12; // [sp+2Ch] [bp-Ch]@1
  int v13; // [sp+2Ch] [bp-Ch]@9
  int v14; // [sp+2Ch] [bp-Ch]@16
  int v15; // [sp+2Ch] [bp-Ch]@23

  v12 = -2097152;
  v7 = vFFE00020;
  if ( vFFE00028 == 1213613663 || (v12 = -4194304, v7 = vFFC00020, vFFC00028 == 1213613663) )
  {
    v3 = 0;
    for ( i = 0; i <= 0x1F; ++i )
      v3 += *(_WORD *)(v12 + 2 * i);
    if ( v3 )
    {
      v2 = 0x40000000;
    }
    else
    {
      v13 = v7 + v12;
      if ( *(_DWORD *)(v13 + 40) == 1213613663 )
      {
        v4 = 0;
        for ( j = 0; j <= 0x1F; ++j )
          v4 += *(_WORD *)(v13 + 2 * j);
        if ( v4 )
        {
          v2 = 1073741839;
        }
        else
        {
          v14 = *(_DWORD *)(v13 + 32) + v13;
          if ( *(_DWORD *)(v14 + 40) == 1213613663 )
          {
            v5 = 0;
            for ( k = 0; k <= 0x1F; ++k )
              v5 += *(_WORD *)(v14 + 2 * k);
            if ( v5 )
            {
              v2 = 1073741840;
            }
            else
            {
              v15 = *(_DWORD *)(v14 + 32) + v14;
              v0 = *(_DWORD *)(v15 + 32);
              if ( *(_DWORD *)(v15 + 40) == 1213613663 )
              {
                v6 = 0;
                for ( l = 0; l <= 0x1F; ++l )
                  v6 += *(_WORD *)(v15 + 2 * l);
                if ( v6 )
                  v2 = 1073741842;
                else
                  v2 = 0;
              }
              else
              {
                v2 = 1073741841;
              }
            }
          }
          else
          {
            v2 = 1073741838;
          }
        }
      }
      else
      {
        v2 = 1073741837;
      }
    }
  }
  else
  {
    v2 = 1073741836;
  }
  return v2;
}

//----- (00002F3A) --------------------------------------------------------
int __cdecl sub_2F3A(int a1)
{
  int v2; // [sp+18h] [bp-10h]@1
  int v3; // [sp+1Ch] [bp-Ch]@1

  v3 = 0;
  v2 = 0;
  sub_3392(a1, 76, (int)&v2, 1u);
  v2 = 0;
  sub_3392(a1, 71, (int)&v2, 1u);
  v2 = 254;
  sub_3392(a1, 68, (int)&v2, 1u);
  return v3;
}

//----- (000030A3) --------------------------------------------------------
int __cdecl sub_30A3(int a1)
{
  int v2; // [sp+18h] [bp-10h]@1
  int v3; // [sp+1Ch] [bp-Ch]@1

  v3 = 0;
  sub_3392(a1, 68, (int)&v2, 0);
  if ( (unsigned __int8)v2 == 253 )
  {
    v3 = -1073741819;
  }
  else if ( v2 & 0x20000000 )
  {
    v3 = -1073741818;
  }
  else if ( (unsigned __int8)v2 == 254 )
  {
    sub_3392(a1, 76, (int)&v2, 0);
    if ( v2 & 1 )
      v3 = 1073741829;
    if ( v2 & 2 )
      v3 = 1073741830;
    if ( v2 & 4 )
      v3 = 1073741831;
    if ( v2 & 8 )
      v3 = 1073741832;
    if ( v2 & 0x10 )
      v3 = 1073741833;
  }
  else
  {
    v3 = -1073741822;
  }
  v2 = 0;
  sub_3392(a1, 76, (int)&v2, 1u);
  v2 = 0;
  sub_3392(a1, 71, (int)&v2, 1u);
  return v3;
}

//----- (000031EB) --------------------------------------------------------
int __cdecl sub_31EB(int a1)
{
  int v2; // [sp+18h] [bp-10h]@1
  int v3; // [sp+1Ch] [bp-Ch]@1

  v3 = 0;
  v2 = 0;
  sub_3392(a1, 76, (int)&v2, 1u);
  v2 = 31;
  v3 = sub_3392(a1, 72, (int)&v2, 1u);
  v2 = 128;
  return sub_3392(a1, 71, (int)&v2, 1u);
}

//----- (00003392) --------------------------------------------------------
int __cdecl sub_3392(int a1, int a2, int a3, unsigned int a4)
{
  int v5; // [sp+2Ch] [bp-13Ch]@2
  char v6[68]; // [sp+4Ch] [bp-11Ch]@1
  unsigned __int8 v7; // [sp+90h] [bp-D8h]@3
  unsigned __int8 v8; // [sp+91h] [bp-D7h]@3
  unsigned __int8 v9; // [sp+92h] [bp-D6h]@3
  unsigned __int8 v10; // [sp+93h] [bp-D5h]@3
  unsigned __int8 v11; // [sp+94h] [bp-D4h]@3
  unsigned __int8 v12; // [sp+95h] [bp-D3h]@3
  unsigned __int8 v13; // [sp+96h] [bp-D2h]@3
  unsigned __int8 v14; // [sp+97h] [bp-D1h]@3
  unsigned __int8 v15; // [sp+98h] [bp-D0h]@3
  unsigned __int8 v16; // [sp+99h] [bp-CFh]@3
  unsigned __int8 v17; // [sp+9Ah] [bp-CEh]@3
  unsigned __int8 v18; // [sp+9Bh] [bp-CDh]@3
  int v19; // [sp+14Ch] [bp-1Ch]@1
  int v20; // [sp+150h] [bp-18h]@1
  int v21; // [sp+154h] [bp-14h]@3
  int v22; // [sp+158h] [bp-10h]@3
  int v23; // [sp+15Ch] [bp-Ch]@3

  v20 = ((int (__cdecl *)(_DWORD))**(_DWORD **)L"4x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x")(*(_DWORD *)L"4x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x");
  v19 = (*(int (__cdecl **)(_DWORD, _DWORD, int, _DWORD))(*(_DWORD *)L"4x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" + 4))(
          *(_DWORD *)L"4x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
          v6,
          v20,
          0);
  if ( v19 >= 0 )
  {
    v22 = (v13 << 16) + (v12 << 8) + v11 + (v14 << 24);
    v21 = (v17 << 16) + (v16 << 8) + v15 + (v18 << 24);
    v23 = (v9 << 16) + (v8 << 8) + v7 + (v10 << 24);
    if ( a4 )
    {
      v6[a2] = *(_DWORD *)a3 % 0xFFu;
      if ( a4 > 1 )
        v6[a2 + 1] = (*(_DWORD *)a3 >> 8) % 0xFFu;
      if ( a4 > 2 )
        v6[a2 + 2] = (*(_DWORD *)a3 >> 16) % 0xFFu;
      if ( a4 > 3 )
        v6[a2 + 3] = (*(_DWORD *)a3 >> 24) % 0xFFu;
      (*(void (__cdecl **)(_DWORD, char *, signed int, int))(*(_DWORD *)L"4x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" + 8))(
        *(_DWORD *)L"4x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        &v6[a2],
        4,
        a2);
    }
    else
    {
      *(_DWORD *)a3 = ((unsigned __int8)v6[a2 + 2] << 16)
                    + ((unsigned __int8)v6[a2 + 1] << 8)
                    + (unsigned __int8)v6[a2]
                    + ((unsigned __int8)v6[a2 + 3] << 24);
    }
    v5 = v19;
  }
  else
  {
    v5 = v19;
  }
  return v5;
}
// EEA8: using guessed type __int16 a8x04x04x02x02x[47];
// 3392: using guessed type char var_11C[68];

//----- (00003E75) --------------------------------------------------------
// write access to const memory has been detected, the output may be wrong!
int __cdecl sub_3E75(int a1)
{
  int result; // eax@7
  int v2; // [sp+Ch] [bp-1Ch]@2
  signed int i; // [sp+1Ch] [bp-Ch]@4

  if ( a1 )
    v2 = a1;
  else
    v2 = 5489;
  dword_F150[0] = v2;
  for ( i = 1; i <= 623; ++i )
    dword_F150[i] = i + 1812433253 * (dword_F150[i - 1] ^ ((unsigned int)dword_F150[i - 1] >> 30));
  result = (int)dword_F0D0;
  dword_F0D0[0] = 1;
  return result;
}
// 3EA1: write access to const memory at F150 has been detected
// 3EF4: write access to const memory at F0D0 has been detected
// F0D0: using guessed type int dword_F0D0[32];
// F150: using guessed type int dword_F150[21];

//----- (0000412E) --------------------------------------------------------
bool __cdecl sub_412E(int a1)
{
  int v3; // [sp+24h] [bp-24h]@1
  signed int v4; // [sp+2Ch] [bp-1Ch]@1
  int i; // [sp+30h] [bp-18h]@1
  int v6; // [sp+38h] [bp-10h]@2
  int v7; // [sp+3Ch] [bp-Ch]@4

  v3 = sub_7034(a1);
  v4 = 0;
  for ( i = 0; i < v3; ++i )
  {
    v6 = sub_6C92((int)dword_EF90, *(_BYTE *)(a1 - 1 + v3 - i));
    if ( !v6 )
      return 0;
    v7 = v6 - (_DWORD)dword_EF90;
    if ( i & 1 )
      v4 += 3 * v7;
    else
      v4 += v7;
  }
  return v4 % 34 == 0;
}
// EF90: using guessed type int dword_EF90[9];

//----- (000048DC) --------------------------------------------------------
// write access to const memory has been detected, the output may be wrong!
signed int __cdecl sub_48DC(int a1)
{
  int (__cdecl *v1)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); // edi@12
  int v2; // esi@12
  int v3; // eax@12
  int (__cdecl *v4)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD); // edi@17
  int v5; // esi@17
  int v6; // eax@17
  int v7; // eax@24
  char v9; // [sp+10h] [bp-358h]@0
  char v11[256]; // [sp+34h] [bp-334h]@20
  __int16 v12; // [sp+134h] [bp-234h]@19
  int v13; // [sp+334h] [bp-34h]@2
  int v14; // [sp+338h] [bp-30h]@1
  int v15; // [sp+33Ch] [bp-2Ch]@1
  int i; // [sp+340h] [bp-28h]@8
  int j; // [sp+344h] [bp-24h]@20
  char v18; // [sp+34Bh] [bp-1Dh]@1
  int v19; // [sp+34Ch] [bp-1Ch]@30

  v14 = 0;
  v18 = 0;
  v15 = (*(int (__cdecl **)(_DWORD, _DWORD, int *))(unk_0 + 172))(0, 0, &dword_EFCC);
  if ( !v15 )
    return v15;
  v15 = (*(int (__cdecl **)(int, int, int *))(unk_0 + 88))(a1, dword_FC44[0], &v13);
  if ( !v15 )
  {
    if ( !*(_DWORD *)(v13 + 16) )
    {
      sub_5FAF(1952673887, 1480938066, 0, (int)"hic Arts Prepress Device", v9);
      return -2147483646;
    }
    v15 = (*(int (__cdecl **)(_DWORD, _DWORD, int *))(unk_0 + 88))(*(_DWORD *)(v13 + 12), 0, &v14);
    if ( v15 )
      return v15;
    for ( i = v14; (*(_BYTE *)i & 0x7F) != 127 || *(_BYTE *)(i + 1) != -1; i += *(_BYTE *)(i + 2) | (*(_BYTE *)(i + 3) << 8) )
    {
      if ( (*(_BYTE *)i & 0x7F) == 3 && (*(_BYTE *)(i + 1) == 11 || *(_BYTE *)(i + 1) == 12) )
      {
        v14 = sub_A03E(v14, *(_DWORD *)(v13 + 16));
        sub_80C5(v14, 0);
        v18 = 1;
        v1 = *(int (__cdecl **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(unk_0 + 56);
        v2 = v14;
        v3 = sub_9DAC(v14);
        v15 = v1(&unk_DD00, dword_EFBC, 2, v3, v2);
        (*(void (__cdecl **)(int))(unk_0 + 48))(v14);
        break;
      }
    }
    if ( !v18 )
    {
      v4 = *(int (__cdecl **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(unk_0 + 56);
      v5 = v14;
      v6 = sub_9DAC(v14);
      v15 = v4(&unk_DD00, dword_EFBC, 2, v6, v5);
    }
    if ( !v15 )
    {
      if ( sub_80C5(*(_DWORD *)(v13 + 16), (int)&v12) )
      {
        v11[0] = 0;
        v15 = sub_54CB((int)"ices Device", (int)"ptical Memory Device");
      }
      else
      {
        sub_6893((int)&v12, (int)v11, 256);
        for ( j = 0; ; ++j )
        {
          v7 = sub_7034((int)v11);
          if ( v7 <= j )
            break;
          if ( v11[j] == 92 )
            v11[j] = 47;
        }
        if ( sub_6F8B((int)v11, (int)"r")
          && !sub_6D34((int)v11, (int)"Enclosure Services Device")
          && !sub_6D34((int)v11, (int)"re Services Device")
          && v11[sub_7034((int)v11) - 1] != 47 )
          sub_6BCE((int)v11, (int)"r");
        v19 = sub_6CC2((int)v11, 0x2Fu);
        if ( v19 )
        {
          ++v19;
          *(_BYTE *)v19 = 0;
        }
        if ( v11[sub_7034((int)v11) - 1] != 47 )
          sub_6BCE((int)v11, (int)"r");
        if ( sub_7034((int)v11) )
          v15 = sub_54CB((int)"ices Device", (int)v11);
      }
    }
    if ( v18 )
    {
      sub_6BCE((int)v11, (int)"lified Direct Access Device");
      sub_683B((int)v11, (int)&v12, 256);
    }
    else
    {
      v12 = 0;
    }
    sub_BACB((int)&v12, (int)L"location");
    if ( !v15 )
      v15 = sub_849A(a1, (int)&v12, (int)&dword_EFB4, 0);
    if ( v15 )
      sub_B563((int)&off_DD50, v15);
    else
      v15 = (*(int (__cdecl **)(_DWORD, _DWORD, int *))(unk_0 + 172))(0, 0, &dword_EFCC);
    return v15;
  }
  return v15;
}
// 4DFE: write access to const memory at EFB8 has been detected
// DD18: using guessed type __int16 aLocation[9];
// EFB4: using guessed type int dword_EFB4;
// EFB8: using guessed type int dword_EFB8;
// EFBC: using guessed type int dword_EFBC[4];
// EFCC: using guessed type int dword_EFCC;
// FC44: using guessed type int dword_FC44[2];
// 48DC: using guessed type char var_334[256];

//----- (00004E73) --------------------------------------------------------
int __cdecl sub_4E73(int a1, int a2)
{
  return unk_20(a1, a2);
}

//----- (00004EA0) --------------------------------------------------------
int __cdecl sub_4EA0(int a1)
{
  return ((int (__cdecl *)(int))unk_10C3E)(a1);
}

//----- (00004EC6) --------------------------------------------------------
int __cdecl sub_4EC6(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
{
  return (*(int (__cdecl **)(int, int, int, int, int, int, int, int))((char *)&off_37 + 1))(
           a1,
           a2,
           a3,
           a4,
           a5,
           a6,
           a7,
           a8);
}
// 37: using guessed type void *off_37;

//----- (00004F1D) --------------------------------------------------------
int __cdecl sub_4F1D(int a1, int a2)
{
  return unk_3C(a1, a2);
}

//----- (00004F4A) --------------------------------------------------------
int __cdecl sub_4F4A(int a1, int a2)
{
  return unk_40(a1, a2);
}

//----- (00004F77) --------------------------------------------------------
int __cdecl sub_4F77(int a1)
{
  return unk_44(a1);
}

//----- (00004F9D) --------------------------------------------------------
int __cdecl sub_4F9D(int a1, int a2, int a3, int a4, __int16 a5, int a6, __int16 a7)
{
  __int16 v7; // ST1C_2@1
  __int16 v8; // ST14_2@1

  v7 = a7;
  v8 = a5;
  return unk_48(a1, a2, a3, a4);
}

//----- (00004FF8) --------------------------------------------------------
int __cdecl sub_4FF8(int a1)
{
  return ((int (__cdecl *)(int))dword_4C[0])(a1);
}
// 4C: using guessed type int dword_4C[8];

//----- (000051CE) --------------------------------------------------------
int __cdecl sub_51CE(int a1, int a2, int a3, int a4)
{
  return ((int (__cdecl *)(int, int, int, int))dword_74[11])(a1, a2, a3, a4);
}
// 74: using guessed type int dword_74[13];

//----- (000054CB) --------------------------------------------------------
int __cdecl sub_54CB(int a1, int a2)
{
  char v3; // [sp+28h] [bp-210h]@1
  int v4; // [sp+22Ch] [bp-Ch]@2

  sub_683B(a1, (int)&v3, 256);
  if ( a2 )
    v4 = sub_7034(a2) + 1;
  else
    v4 = 0;
  return (*(int (__cdecl **)(char *, _DWORD, signed int, int, int))(unk_0 + 56))(&v3, dword_EFBC, 2, v4, a2);
}
// EFBC: using guessed type int dword_EFBC[4];

//----- (00005FAF) --------------------------------------------------------
int __cdecl sub_5FAF(int a1, int a2, int a3, int a4, char a5)
{
  return ((int (__cdecl *)(int, int, int, int, char *))dword_158[12])(a1, a2, a3, a4, &a5);
}
// 158: using guessed type int[20];

//----- (000061E8) --------------------------------------------------------
int __cdecl sub_61E8(int a1, int a2, int a3, int a4, int a5, int a6)
{
  return ((int (__cdecl *)(int, int, int, int, int, int))dword_158[18])(a1, a2, a3, a4, a5, a6);
}
// 158: using guessed type int dword_158[20];

//----- (00006234) --------------------------------------------------------
int __cdecl sub_6234(int a1, int a2, int a3, int a4)
{
  return ((int (__cdecl *)(int, int, int, int))dword_158[17])(a1, a2, a3, a4);
}
// 158: using guessed type int dword_158[20];

//----- (00006374) --------------------------------------------------------
#error "6399: positive sp value has been found (funcsize=13)"

//----- (000064C8) --------------------------------------------------------
int __cdecl sub_64C8(char a1, int a2, int a3, int a4, int a5)
{
  return loc_4(a1, a2, a3, a4, a5);
}

//----- (00006511) --------------------------------------------------------
int __cdecl sub_6511(char a1, int a2, int a3, int a4, unsigned __int8 a5)
{
  return (*(int (__cdecl **)(_DWORD, int, int, int, _DWORD))((char *)&loc_7 + 1))(a1, a2, a3, a4, a5);
}

//----- (00006561) --------------------------------------------------------
int sub_6561()
{
  return unk_C();
}

//----- (0000683B) --------------------------------------------------------
int __cdecl sub_683B(int a1, int a2, int a3)
{
  int v4; // [sp+8h] [bp-10h]@1
  int i; // [sp+Ch] [bp-Ch]@1

  v4 = a2;
  for ( i = 0; *(_BYTE *)a1 && a3 - 1 > i; ++i )
  {
    *(_WORD *)a2 = *(_BYTE *)a1;
    a2 += 2;
    ++a1;
  }
  if ( a3 - 1 > i )
    *(_WORD *)a2 = 0;
  return v4;
}

//----- (00006893) --------------------------------------------------------
int __cdecl sub_6893(int a1, int a2, int a3)
{
  int v4; // [sp+8h] [bp-10h]@1
  int i; // [sp+Ch] [bp-Ch]@1

  v4 = a2;
  for ( i = 0; *(_WORD *)a1 && a3 - 1 > i; ++i )
  {
    *(_BYTE *)a2++ = *(_WORD *)a1;
    a1 += 2;
  }
  if ( a3 - 1 > i )
    *(_BYTE *)a2 = 0;
  return v4;
}

//----- (00006987) --------------------------------------------------------
int __cdecl sub_6987(unsigned __int8 a1, int a2)
{
  return ((int (__cdecl *)(_DWORD, int))dword_124[1])(a1, a2);
}
// 124: using guessed type int[8];

//----- (00006BCE) --------------------------------------------------------
int __cdecl sub_6BCE(int a1, int a2)
{
  char v2; // al@4
  int v4; // [sp+4h] [bp-14h]@1
  int v5; // [sp+8h] [bp-10h]@1

  v4 = 0;
  v5 = 0;
  while ( *(_BYTE *)(a1 + v4) )
    ++v4;
  do
  {
    *(_BYTE *)(a1 + v4) = *(_BYTE *)(a2 + v5);
    v2 = *(_BYTE *)(a1 + v4++) != 0;
    ++v5;
  }
  while ( v2 );
  return a1;
}

//----- (00006C92) --------------------------------------------------------
int __cdecl sub_6C92(int a1, int a2)
{
  return unk_230(a1, a2);
}

//----- (00006CC2) --------------------------------------------------------
int __cdecl sub_6CC2(int a1, unsigned __int8 a2)
{
  int v3; // [sp+8h] [bp-20h]@6
  int v4; // [sp+Ch] [bp-1Ch]@8
  int v5; // [sp+10h] [bp-18h]@1
  int v6; // [sp+14h] [bp-14h]@1

  v5 = a1 - 1;
  v6 = 0;
  while ( 1 )
  {
    ++v5;
    if ( !*(_BYTE *)v5 )
      break;
    if ( *(_BYTE *)v5 == a2 )
      v6 = v5;
  }
  if ( v6 )
  {
    v3 = v6;
  }
  else
  {
    if ( a2 )
      v4 = 0;
    else
      v4 = v5;
    v3 = v4;
  }
  return v3;
}

//----- (00006D34) --------------------------------------------------------
int __cdecl sub_6D34(int a1, int a2)
{
  int v3; // [sp+Ch] [bp-2Ch]@3
  int v4; // [sp+14h] [bp-24h]@1
  int v5; // [sp+28h] [bp-10h]@5
  int v6; // [sp+2Ch] [bp-Ch]@5

  v4 = a1 - 1;
  if ( a2 && *(_BYTE *)a2 )
  {
    while ( 1 )
    {
      ++v4;
      if ( !*(_BYTE *)v4 )
        break;
      if ( *(_BYTE *)v4 == *(_BYTE *)a2 )
      {
        v5 = v4 - 1;
        v6 = a2 - 1;
        do
        {
          ++v5;
          ++v6;
        }
        while ( *(_BYTE *)v5 == *(_BYTE *)v6 && *(_BYTE *)v5 );
        if ( !*(_BYTE *)v6 )
          return v4;
      }
    }
    v3 = 0;
  }
  else
  {
    v3 = a1;
  }
  return v3;
}

//----- (00006EC6) --------------------------------------------------------
int __cdecl sub_6EC6(int a1, int a2, int a3)
{
  return ((int (__cdecl *)(int, int, int))dword_244[3])(a1, a2, a3);
}
// 244: using guessed type int[4];

//----- (00006EFD) --------------------------------------------------------
int __cdecl sub_6EFD(int a1, int a2, char a3)
{
  return sub_6EC6(a1, a2, (int)&a3);
}

//----- (00006F24) --------------------------------------------------------
int __cdecl sub_6F24(int a1, int a2)
{
  return ((int (__cdecl *)(int, int))((char *)&loc_5FE + 2))(a1, a2);
}

//----- (00006F8B) --------------------------------------------------------
int __cdecl sub_6F8B(int a1, int a2)
{
  while ( *(_BYTE *)a1 && *(_BYTE *)a1 == *(_BYTE *)a2 )
  {
    ++a1;
    ++a2;
  }
  return *(_BYTE *)a1 - *(_BYTE *)a2;
}

//----- (00007034) --------------------------------------------------------
int __cdecl sub_7034(int a1)
{
  char v1; // al@3
  int i; // [sp+Ch] [bp-Ch]@1

  for ( i = 0; ; ++i )
  {
    v1 = *(_BYTE *)a1++ != 0;
    if ( !v1 )
      break;
  }
  return i;
}

//----- (00007B34) --------------------------------------------------------
int sub_7B34()
{
  int result; // eax@1
  int v1; // [sp+20h] [bp-18h]@1
  unsigned int v2; // [sp+24h] [bp-14h]@1
  int v3; // [sp+28h] [bp-10h]@1
  unsigned int i; // [sp+2Ch] [bp-Ch]@2

  result = (*(int (__cdecl **)(_DWORD, _DWORD, _DWORD, unsigned int *, int *))(unk_0 + 168))(0, 0, 0, &v2, &v1);
  v3 = result;
  if ( result >= 0 )
  {
    for ( i = 0; i < v2; ++i )
      (*(void (__cdecl **)(_DWORD, _DWORD, _DWORD, signed int))(unk_0 + 144))(*(_DWORD *)(4 * i + v1), 0, 0, 1);
    (*(void (__cdecl **)(int))(unk_0 + 48))(v1);
    result = (*(int (**)(void))(*(_DWORD *)dword_FC74[0] + 76))();
  }
  return result;
}
// FC74: using guessed type int dword_FC74[3];

//----- (00007C00) --------------------------------------------------------
int __cdecl sub_7C00(int a1, int a2, unsigned int a3)
{
  int v3; // eax@12
  unsigned int v4; // esi@17
  char v5; // al@19
  signed int v7; // [sp+2Ch] [bp-69Ch]@3
  char v8; // [sp+30h] [bp-698h]@9
  __int16 v9[512]; // [sp+230h] [bp-498h]@4
  __int16 _62F[512]; // [sp+62Fh] [bp-99h]@7
  char v11[128]; // [sp+630h] [bp-98h]@4
  int v12; // [sp+6B0h] [bp-18h]@6
  int v13; // [sp+6B4h] [bp-14h]@6
  unsigned int i; // [sp+6B8h] [bp-10h]@13
  __int16 *v15; // [sp+6BCh] [bp-Ch]@7

  if ( a2 && a3 )
  {
    sub_B71B((int)v11, (int)"lified Direct Access Device");
    v9[0] = 0;
    if ( !sub_830D() && *(_WORD *)a1 != 47 )
    {
      v12 = 128;
      v13 = (*(int (__cdecl **)(_DWORD, int, _DWORD, int *, _DWORD))(unk_0 + 48))(
              L"-number2",
              dword_FC3C[0],
              0,
              &v12,
              v11);
      if ( v11[v12 - 2] != 47 )
      {
        v15 = (__int16 *)((char *)_62F + v12);
        *((_BYTE *)_62F + v12) = 47;
        v15 = (__int16 *)((char *)v15 + 1);
        *(_BYTE *)v15 = 0;
      }
      if ( v11[0] != 47 )
      {
        v12 = 512;
        v13 = (*(int (__cdecl **)(_DWORD, int, _DWORD, int *, char *))(unk_0 + 48))(
                L"serial-number3",
                dword_FC3C[0],
                0,
                &v12,
                &v8);
        if ( v13 < 0 )
          return v13;
        sub_683B((int)&v8, (int)v9, 512);
      }
      v3 = sub_B680((int)v9);
      sub_683B((int)v11, (int)&v9[v3], 128);
    }
    sub_BACB((int)v9, a1);
    for ( i = 0; ; ++i )
    {
      v4 = i;
      if ( v4 >= sub_B680((int)v9) )
        break;
      if ( v9[i] == 47 )
        v9[i] = 92;
    }
    if ( sub_B8EA((int)v9) <= a3 )
    {
      sub_B65D(a2, (int)v9);
      v7 = 0;
    }
    else
    {
      v5 = sub_B8EA((int)v9);
      sub_B563((int)L"\u6900\u6100\u6c00\u2d00\u6e00\u7500\u6d00\u6200\u6500\u7200\u3300", v5);
      v7 = -2147483639;
    }
  }
  else
  {
    v7 = -2147483646;
  }
  return v7;
}
// DD90: using guessed type __int16 aNumber2[9];
// DDAC: using guessed type __int16 aSerialNumber3[15];
// FC3C: using guessed type int dword_FC3C[2];
// 7C00: using guessed type char var_98[128];
// 7C00: using guessed type __int16 var_498[512];

//----- (00007E67) --------------------------------------------------------
int __cdecl sub_7E67(int a1, char a2, int a3)
{
  int v4; // [sp+28h] [bp-B0h]@11
  bool v5; // [sp+3Ch] [bp-9Ch]@13
  char v6; // [sp+43h] [bp-95h]@10
  __int16 v7[64]; // [sp+44h] [bp-94h]@6
  int v8; // [sp+C4h] [bp-14h]@10
  int i; // [sp+C8h] [bp-10h]@1
  int v10; // [sp+CCh] [bp-Ch]@5

  for ( i = a1 + 2 * sub_B680(a1) - 2; *(_WORD *)i && *(_WORD *)i != 92; i -= 2 )
    ;
  i += 2;
  v10 = 0;
  while ( *(_WORD *)i && *(_WORD *)i != 46 )
  {
    v7[v10++] = *(_WORD *)i;
    i += 2;
  }
  v7[v10] = 0;
  if ( a2 )
  {
    v5 = 1;
    v8 = (*(int (__cdecl **)(_DWORD, int, _DWORD, bool *, char *))(unk_0 + 48))(v7, dword_FC3C[0], 0, &v5, &v6);
    if ( v8 >= 0 )
    {
      if ( a2 == 1 )
      {
        ++v6;
      }
      else if ( a2 == 2 )
      {
        --v6;
      }
      v5 = v6 != 0;
      *(_BYTE *)a3 = v6;
      v8 = (*(int (__cdecl **)(_DWORD, int, signed int, bool, char *))(unk_0 + 56))(v7, dword_FC3C[0], 2, v5, &v6);
      v4 = v8;
    }
    else
    {
      sub_B563((int)L"\u7600\u6500\u7200\u7300\u6900\u6f00\u6e00", v8);
      v4 = v8;
    }
  }
  else
  {
    v6 = 1;
    v8 = (*(int (__cdecl **)(_DWORD, int, signed int, signed int, char *))(unk_0 + 56))(v7, dword_FC3C[0], 2, 1, &v6);
    if ( v8 >= 0 )
    {
      *(_BYTE *)a3 = v6;
      v4 = 0;
    }
    else
    {
      sub_B563((int)L":%02x", v8);
      v4 = v8;
    }
  }
  return v4;
}
// DE3C: using guessed type __int16 a02x[6];
// DE90: using guessed type __int16 aMcVersion[11];
// FC3C: using guessed type int dword_FC3C[2];
// 7E67: using guessed type __int16 var_94[64];

//----- (000080C5) --------------------------------------------------------
signed int __cdecl sub_80C5(int a1, int a2)
{
  signed int v3; // [sp+1Ch] [bp-41Ch]@12
  __int16 v4[512]; // [sp+28h] [bp-410h]@1
  int v5; // [sp+428h] [bp-10h]@1
  int v6; // [sp+42Ch] [bp-Ch]@4

  v4[0] = 0;
  v5 = 0;
  while ( (*(_BYTE *)a1 & 0x7F) != 127 || *(_BYTE *)(a1 + 1) != -1 )
  {
    if ( (*(_BYTE *)a1 & 0x7F) == 4 && *(_BYTE *)(a1 + 1) == 4 )
    {
      v6 = a1;
      if ( !a2 )
      {
        *(_BYTE *)a1 = 127;
        *(_BYTE *)(a1 + 1) = -1;
        *(_BYTE *)(a1 + 2) = 4;
        *(_BYTE *)(a1 + 3) = 0;
        return 0;
      }
      if ( v5 )
      {
        if ( v4[v5] != 92 && v4[v5] != 47 )
          sub_BACB((int)v4, (int)L"vision");
        sub_BACB((int)v4, v6 + 4);
      }
      else
      {
        sub_BACB((int)v4, v6 + 4);
      }
      v5 = sub_B680((int)v4);
    }
    a1 += *(_BYTE *)(a1 + 2) | (*(_BYTE *)(a1 + 3) << 8);
  }
  if ( v5 )
  {
    sub_B65D(a2, (int)v4);
    v3 = 0;
  }
  else
  {
    v3 = -2147483634;
  }
  return v3;
}
// DF38: using guessed type __int16 aVision[7];
// 80C5: using guessed type __int16 var_410[512];

//----- (00008252) --------------------------------------------------------
signed int __cdecl sub_8252(int a1)
{
  signed int v2; // [sp+2Ch] [bp-41Ch]@2
  int v3; // [sp+38h] [bp-410h]@1
  char v4; // [sp+3Ch] [bp-40Ch]@1
  int v5; // [sp+43Ch] [bp-Ch]@1

  v3 = 512;
  v5 = (*(int (__cdecl **)(__int16 *, int, _DWORD, int *, char *))(unk_0 + 48))(
         L"\u6900\u7300\u6900\u6f00\u6e00",
         dword_FC3C[0],
         0,
         &v3,
         &v4);
  if ( v5 )
  {
    v2 = v5;
  }
  else
  {
    *(_DWORD *)a1 = sub_A90D(v3, (int)&v4);
    if ( *(_DWORD *)a1 )
      v2 = 0;
    else
      v2 = -2147483639;
  }
  return v2;
}
// DF38: using guessed type __int16 aVision[7];
// FC3C: using guessed type int dword_FC3C[2];

//----- (0000830D) --------------------------------------------------------
// write access to const memory has been detected, the output may be wrong!
signed int sub_830D()
{
  signed int v1; // [sp+1Ch] [bp-1Ch]@2
  int v2; // [sp+28h] [bp-10h]@3
  int i; // [sp+2Ch] [bp-Ch]@5

  if ( LOBYTE(dword_EFD0[0]) )
  {
    v1 = 1;
  }
  else if ( sub_8252((int)&v2) )
  {
    v1 = 0;
  }
  else
  {
    for ( i = v2; (*(_BYTE *)i & 0x7F) != 127 || *(_BYTE *)(i + 1) != -1; i += *(_BYTE *)(i + 2) | (*(_BYTE *)(i + 3) << 8) )
    {
      if ( (*(_BYTE *)i & 0x7F) == 3 && (*(_BYTE *)(i + 1) == 11 || *(_BYTE *)(i + 1) == 12) )
      {
        LOBYTE(dword_EFD0[0]) = 1;
        break;
      }
    }
    (*(void (__cdecl **)(int))(unk_0 + 48))(v2);
    v1 = LOBYTE(dword_EFD0[0]);
  }
  return v1;
}
// 8383: write access to const memory at EFD0 has been detected
// EFD0: using guessed type int dword_EFD0[12];

//----- (0000849A) --------------------------------------------------------
signed int __cdecl sub_849A(int a1, int a2, int a3, char a4)
{
  signed int v5; // [sp+28h] [bp-440h]@4
  int v6; // [sp+34h] [bp-434h]@20
  char v7; // [sp+3Bh] [bp-42Dh]@15
  int v8; // [sp+3Ch] [bp-42Ch]@7
  int v9; // [sp+40h] [bp-428h]@1
  unsigned int v10; // [sp+44h] [bp-424h]@1
  char v11; // [sp+48h] [bp-420h]@3
  int v12; // [sp+448h] [bp-20h]@24
  int v13; // [sp+44Ch] [bp-1Ch]@24
  int v14; // [sp+450h] [bp-18h]@3
  int v15; // [sp+454h] [bp-14h]@20
  int v16; // [sp+458h] [bp-10h]@22
  unsigned int i; // [sp+45Ch] [bp-Ch]@6

  v10 = 0;
  v9 = 0;
  if ( a3 )
    *(_DWORD *)a3 = 0;
  v14 = sub_7C00(a2, (int)&v11, 0x200u);
  if ( v14 >= 0 )
  {
    v14 = (*(int (__cdecl **)(signed int, int, _DWORD, unsigned int *, int *))(unk_0 + 168))(
            2,
            dword_FC44[0],
            0,
            &v10,
            &v9);
    if ( v14 >= 0 )
    {
      for ( i = 0; i < v10; ++i )
      {
        v14 = (*(int (__cdecl **)(_DWORD, int, int *))(unk_0 + 88))(*(_DWORD *)(4 * i + v9), dword_FC44[0], &v8);
        if ( *(_DWORD *)(v8 + 16) && (**(_BYTE **)(v8 + 16) != 4 || *(_BYTE *)(*(_DWORD *)(v8 + 16) + 1) != 6) )
        {
          if ( v14 >= 0 )
          {
            if ( !sub_B694((unsigned __int16 *)&v11, *(_DWORD *)(v8 + 16) + 4) )
            {
              if ( a3 )
                *(_DWORD *)a3 = *(_DWORD *)(4 * i + v9);
              v14 = sub_7E67((int)&v11, 1, (int)&v7);
              if ( v14 >= 0 )
              {
                (*(void (__cdecl **)(int))(unk_0 + 48))(v9);
                return -2147483628;
              }
            }
          }
          else
          {
            sub_B563(
              (int)L"\u6200\u7200\u6900\u6400\u6700\u6500\u2d00\u6400\u6500\u7600\u6900\u6300\u6500\u2d00\u6900\u6400",
              v14);
          }
        }
      }
      (*(void (__cdecl **)(int))(unk_0 + 48))(v9);
    }
    v15 = sub_A1CB(0, (int)&v11);
    v14 = sub_8252((int)&v6);
    if ( v14 )
    {
      v5 = v14;
    }
    else
    {
      v16 = sub_9F6C(v6, v15);
      v14 = (*(int (__cdecl **)(_DWORD, int, int, _DWORD))(unk_0 + 112))(0, a1, v16, 0);
      (*(void (__cdecl **)(int))(unk_0 + 48))(v6);
      (*(void (__cdecl **)(int))(unk_0 + 48))(v16);
      if ( v14 )
      {
        v5 = v14;
      }
      else
      {
        v14 = (*(int (__cdecl **)(int, int, int *))(unk_0 + 88))(v12, dword_FC44[0], &v13);
        if ( *(_DWORD *)(v13 + 16) )
        {
          if ( *(_DWORD *)(v13 + 48) == 3 || *(_DWORD *)(v13 + 48) == 5 )
          {
            if ( *(_DWORD *)(v13 + 16) )
            {
              if ( sub_B694((unsigned __int16 *)(*(_DWORD *)(v13 + 16) + 4), (int)&v11) )
              {
                (*(void (__cdecl **)(_DWORD))(unk_0 + 48))(*(_DWORD *)(v13 + 16));
                *(_DWORD *)(v13 + 16) = v15;
              }
              else
              {
                (*(void (__cdecl **)(int))(unk_0 + 48))(v15);
              }
            }
            v14 = (*(int (__cdecl **)(int, _DWORD, _DWORD))(unk_0 + 116))(v12, 0, 0);
            if ( v14 )
            {
              sub_B563((int)L"ults", v14);
            }
            else
            {
              if ( a3 )
                *(_DWORD *)a3 = v12;
              v14 = sub_7E67((int)&v11, 0, (int)&v7);
              if ( v14 < 0 )
                return v14;
              if ( a4 )
                sub_7B34();
            }
            return v14;
          }
          sub_B563((int)L"revision", *(_DWORD *)(v13 + 48));
          v5 = -2147483646;
        }
        else
        {
          sub_5FAF(1952673887, 1480938066, 0, (int)"cess Device", 0);
          v5 = -2147483646;
        }
      }
    }
  }
  else
  {
    v5 = v14;
  }
  return v5;
}
// DF50: using guessed type __int16 aHbridgeDeviceI[18];
// DF8C: using guessed type __int16 aRevision[9];
// DFC0: using guessed type __int16 aUlts[5];
// FC44: using guessed type int dword_FC44[2];

//----- (00008AD4) --------------------------------------------------------
signed int __cdecl sub_8AD4(int a1, int a2, int a3)
{
  signed int v4; // [sp+2Ch] [bp-3Ch]@7
  int v5; // [sp+34h] [bp-34h]@2
  int v6; // [sp+38h] [bp-30h]@2
  int v7; // [sp+3Ch] [bp-2Ch]@2
  int v8; // [sp+40h] [bp-28h]@2
  unsigned int v9; // [sp+44h] [bp-24h]@1
  char v10; // [sp+4Ah] [bp-1Eh]@2
  int v11; // [sp+4Ch] [bp-1Ch]@1
  int v12; // [sp+50h] [bp-18h]@2
  unsigned int v13; // [sp+54h] [bp-14h]@1
  int v14; // [sp+58h] [bp-10h]@2
  unsigned int i; // [sp+5Ch] [bp-Ch]@1

  v9 = 0;
  v11 = (*(int (__cdecl **)(signed int, _DWORD, _DWORD, unsigned int *, int *))(unk_0 + 168))(2, 0, 0, &v9, &a2);
  v13 = 999;
  for ( i = 0; i < v9; ++i )
  {
    v11 = (*(int (__cdecl **)(_DWORD, _DWORD, int))(unk_0 + 88))(*(_DWORD *)(4 * i + a2), 0, a3);
    v12 = *(_DWORD *)a3;
    v11 = (*(int (__cdecl **)(int, int *, int *, int *, int *))(v12 + 56))(v12, &v8, &v7, &v6, &v5);
    v14 = (v6 << 8) | (v7 << 16) | (v8 << 24) | v5;
    v11 = (*(int (__cdecl **)(int, signed int, signed int, signed int, char *))(v12 + 24))(v12, 1, 2, 1, &v10);
    if ( v14 == a1 )
    {
      v13 = i;
      break;
    }
  }
  if ( v13 == 999 )
  {
    v4 = -2147483645;
  }
  else
  {
    v11 = (*(int (__cdecl **)(_DWORD, _DWORD, int))(unk_0 + 88))(*(_DWORD *)(4 * v13 + a2), 0, a3);
    v12 = *(_DWORD *)a3;
    if ( a2 )
      (*(void (__cdecl **)(int))(unk_0 + 48))(a2);
    v4 = 0;
  }
  return v4;
}

//----- (00008CBD) --------------------------------------------------------
int __cdecl sub_8CBD(int a1, unsigned __int8 a2)
{
  unsigned __int8 v3; // [sp+3Bh] [bp-Dh]@1

  (*(void (__cdecl **)(int, _DWORD, _DWORD, signed int, unsigned __int8 *))(a1 + 24))(a1, 0, a2, 1, &v3);
  return v3;
}

//----- (00008D02) --------------------------------------------------------
int __cdecl sub_8D02(int a1, unsigned __int8 a2)
{
  unsigned __int16 v3; // [sp+3Ah] [bp-Eh]@1

  (*(void (__cdecl **)(int, signed int, _DWORD, signed int, unsigned __int16 *))(a1 + 24))(a1, 1, a2, 1, &v3);
  return v3;
}

//----- (000092D9) --------------------------------------------------------
void __usercall sub_92D9(int a1@<ebp>)
{
  char v1; // ST08_1@1
  int v2; // edx@14
  char v3; // [sp+4h] [bp-64h]@1

  *(_WORD *)(a1 - 16) = sub_8D02(*(_DWORD *)(a1 + 8), 0);
  *(_WORD *)(a1 - 14) = sub_8D02(*(_DWORD *)(a1 + 8), 2u);
  *(_BYTE *)(a1 - 11) = sub_8CBD(*(_DWORD *)(a1 + 8), 0xAu);
  *(_BYTE *)(a1 - 10) = sub_8CBD(*(_DWORD *)(a1 + 8), 0xBu);
  *(_BYTE *)(a1 - 9) = sub_8CBD(*(_DWORD *)(a1 + 8), 9u);
  sub_B563((int)L"\u4200\u5f00\u5300\u6500\u7400\u4500\u5300\u5400", v1);
  *(_DWORD *)(a1 - 76) = *(_WORD *)(a1 - 16);
  if ( *(_DWORD *)(a1 - 76) == 5348 )
  {
    sub_B563((int)&unk_E01C, v3);
  }
  else if ( *(_DWORD *)(a1 - 76) > 5348 )
  {
    if ( *(_DWORD *)(a1 - 76) == 5772 )
    {
      sub_B563((int)&aSetmlbreplaced[7], v3);
    }
    else
    {
      if ( *(_DWORD *)(a1 - 76) != 32902 )
        goto LABEL_12;
      sub_B563((int)&aGetrtcramsize[7], v3);
    }
  }
  else
  {
    if ( *(_DWORD *)(a1 - 76) != 4523 )
    {
LABEL_12:
      sub_B563((int)&unk_E06C, *(_WORD *)(a1 - 16));
      goto LABEL_13;
    }
    sub_B563((int)((char *)&dword_E045 + 1), v3);
  }
LABEL_13:
  sub_B563((int)L"\u2000\u2000", *(_WORD *)(a1 - 14));
  *(_DWORD *)(a1 - 72) = *(_BYTE *)(a1 - 10);
  v2 = *(_DWORD *)(a1 - 72);
  JUMPOUT(*(_DWORD *)algn_9429);
}
// E008: using guessed type __int16 aLb_setest[10];
// E024: using guessed type __int16 aSetmlbreplaced[15];
// E045: using guessed type int dword_E045;
// E04C: using guessed type __int16 aGetrtcramsize[14];
// E0BC: using guessed type __int16[4];

//----- (00009DAC) --------------------------------------------------------
int __cdecl sub_9DAC(int a1)
{
  int result; // eax@1
  int v2; // ecx@1

  result = 0;
  v2 = a1;
  if ( a1 )
  {
    while ( (*(_BYTE *)v2 & 0x7F) != 127 || *(_BYTE *)(v2 + 1) != -1 )
      v2 += (*(_BYTE *)(v2 + 3) << 8) | *(_BYTE *)(v2 + 2);
    result = v2 - a1 + 4;
  }
  return result;
}

//----- (00009E8A) --------------------------------------------------------
int __cdecl sub_9E8A(int a1)
{
  int v1; // ecx@1
  int v2; // ecx@6
  int result; // eax@7

  v1 = a1;
  if ( !a1 )
    goto LABEL_11;
  while ( (*(_BYTE *)v1 & 0x7F) != 127 || *(_BYTE *)(v1 + 1) != -1 )
    v1 += (*(_BYTE *)(v1 + 3) << 8) | *(_BYTE *)(v1 + 2);
  v2 = v1 - a1;
  if ( v2 != -4 )
    result = sub_A8A4(v2 + 4, a1);
  else
LABEL_11:
    result = 0;
  return result;
}

//----- (00009F6C) --------------------------------------------------------
int __cdecl sub_9F6C(int a1, int a2)
{
  int v2; // ecx@3
  int i; // ecx@8
  int v5; // edi@12
  int v6; // esi@12
  int v7; // [sp+1Ch] [bp-1Ch]@8

  if ( !a1 )
  {
    a1 = a2;
    return sub_9E8A(a1);
  }
  v2 = a1;
  if ( !a2 )
    return sub_9E8A(a1);
  while ( (*(_BYTE *)v2 & 0x7F) != 127 || *(_BYTE *)(v2 + 1) != -1 )
    v2 += (*(_BYTE *)(v2 + 3) << 8) | *(_BYTE *)(v2 + 2);
  v7 = v2 - a1 + 4;
  for ( i = a2; (*(_BYTE *)i & 0x7F) != 127 || *(_BYTE *)(i + 1) != -1; i += (*(_BYTE *)(i + 3) << 8) | *(_BYTE *)(i + 2) )
    ;
  v5 = i - a2 + 4;
  v6 = sub_A8A4(v5 + v7 - 4, a1);
  if ( v6 )
    (*(void (__cdecl **)(int, int, int))(unk_0 + 188))(v6 + v7 - 4, a2, v5);
  return v6;
}

//----- (0000A03E) --------------------------------------------------------
int __cdecl sub_A03E(int a1, int a2)
{
  int v2; // edi@1
  int v3; // eax@1
  int v4; // esi@1
  int v5; // edx@2

  v2 = 0;
  v3 = sub_A8A4(((*(_BYTE *)(a2 + 3) << 8) | *(_BYTE *)(a2 + 2)) + 4, a2);
  v4 = v3;
  if ( v3 )
  {
    v5 = v3 + ((*(_BYTE *)(v3 + 3) << 8) | *(_BYTE *)(v3 + 2));
    *(_BYTE *)v5 = 127;
    *(_BYTE *)(v5 + 1) = -1;
    *(_BYTE *)(v5 + 2) = 4;
    *(_BYTE *)(v5 + 3) = 0;
    v2 = sub_9F6C(a1, v3);
    (*(void (__cdecl **)(int))(unk_0 + 48))(v4);
  }
  return v2;
}

//----- (0000A1CB) --------------------------------------------------------
int __cdecl sub_A1CB(int a1, int a2)
{
  int v2; // esi@1
  int v3; // eax@4
  int v4; // edi@4
  int v5; // edx@5
  int v7; // [sp+1Ch] [bp-2Ch]@4
  int v8; // [sp+2Ch] [bp-1Ch]@6
  signed int v9; // [sp+38h] [bp-10h]@1

  v2 = 0;
  v9 = 41432;
  while ( *(_WORD *)(a2 + v2) )
    v2 += 2;
  v3 = sub_AA03(v2 + 10);
  v7 = 0;
  v4 = v3;
  if ( v3 )
  {
    *(_BYTE *)v3 = 4;
    *(_BYTE *)(v3 + 1) = 4;
    *(_BYTE *)(v3 + 2) = v2 + 6;
    *(_BYTE *)(v3 + 3) = (unsigned __int16)(v2 + 6) >> 8;
    (*(void (__cdecl **)(int, int, int))(unk_0 + 188))(v3 + 4, a2, v2 + 2);
    v5 = v4 + ((*(_BYTE *)(v4 + 3) << 8) | *(_BYTE *)(v4 + 2));
    *(_BYTE *)v5 = 127;
    *(_BYTE *)(v5 + 1) = -1;
    *(_BYTE *)(v5 + 2) = 4;
    *(_BYTE *)(v5 + 3) = 0;
    v7 = v4;
    if ( a1 )
    {
      v8 = 0;
      (*(void (__cdecl **)(int, _DWORD, int *))(unk_0 + 88))(a1, 0, &v8);
      v7 = sub_9F6C(v8, v4);
      (*(void (__cdecl **)(int))(unk_0 + 48))(v4);
    }
  }
  return v7;
}

//----- (0000A2BD) --------------------------------------------------------
// write access to const memory has been detected, the output may be wrong!
int __cdecl sub_A2BD(int a1, int a2)
{
  unk_0 = a2;
  unk_0 = *(_DWORD *)(a2 + 60);
  unk_0 = *(_DWORD *)(a2 + 56);
  return 0;
}
// A2D0: write access to const memory at 0 has been detected
// A2DB: write access to const memory at 0 has been detected
// A2E6: write access to const memory at 0 has been detected

//----- (0000A539) --------------------------------------------------------
signed int __cdecl sub_A539(int a1, int a2, int a3, int a4)
{
  int v4; // ecx@1
  int v5; // edi@1
  signed int v6; // esi@1
  signed int v7; // edx@4
  signed int v8; // edx@11

  v4 = a2;
  v5 = a3;
  v6 = -2147483646;
  if ( a4 != 0 && a1 != 0 )
  {
    if ( a3 != 0 && a2 != 0 )
    {
LABEL_9:
      if ( *(_BYTE *)v4 )
      {
        v7 = 1;
        do
        {
          if ( *(_BYTE *)(a1 + v7 - 1) != *(_BYTE *)(v4 + v7 - 1) )
          {
            v4 += 3;
            goto LABEL_9;
          }
          ++v7;
        }
        while ( v7 != 4 );
        while ( *(_DWORD *)v5 )
        {
          v8 = 1;
          while ( *(_BYTE *)(a1 + v8 - 1) == *(_BYTE *)(*(_DWORD *)v5 + v8 - 1) )
          {
            ++v8;
            if ( v8 == 4 )
            {
              v6 = 0;
              *(_DWORD *)a4 = *(_DWORD *)(v5 + 4);
              return v6;
            }
          }
          v5 += 8;
        }
      }
    }
    v6 = -2147483645;
  }
  return v6;
}

//----- (0000A5CB) --------------------------------------------------------
int __cdecl sub_A5CB(int a1, int a2, int a3, int a4)
{
  sub_A2BD(a1, a2);
  *(_DWORD *)(a3 + 16) = a1;
  *(_DWORD *)(a3 + 20) = a4;
  return (*(int (__cdecl **)(int, _DWORD, _DWORD, int))(unk_0 + 76))(a3 + 20, 0, 0, a3);
}

//----- (0000A634) --------------------------------------------------------
int __cdecl sub_A634(int a1, int a2, int a3, int a4, int a5, int a6, int a7)
{
  int result; // eax@1

  result = sub_A5CB(a1, a2, a3, a4);
  if ( result >= 0 )
  {
    if ( !a5 || (result = (*(int (__cdecl **)(int, _DWORD, _DWORD, int))(unk_0 + 76))(a3 + 20, 0, 0, a5), result >= 0) )
    {
      if ( !a6 || (result = (*(int (__cdecl **)(int, _DWORD, _DWORD, int))(unk_0 + 76))(a3 + 20, 0, 0, a6), result >= 0) )
      {
        if ( !a7
          || (result = (*(int (__cdecl **)(int, _DWORD, _DWORD, int))(unk_0 + 76))(a3 + 20, 0, 0, a7), result >= 0) )
          result = 0;
      }
    }
  }
  return result;
}

//----- (0000A82A) --------------------------------------------------------
int __cdecl sub_A82A(int a1)
{
  int v2; // [sp+1Ch] [bp-Ch]@1

  v2 = 0;
  (*(void (__cdecl **)(signed int, int, int *))(unk_0 + 44))(4, a1, &v2);
  return v2;
}

//----- (0000A8A4) --------------------------------------------------------
int __cdecl sub_A8A4(int a1, int a2)
{
  int v2; // ecx@1
  int v4; // [sp+1Ch] [bp-1Ch]@1

  v4 = 0;
  (*(void (__cdecl **)(signed int, int, int *))(unk_0 + 44))(4, a1, &v4);
  v2 = v4;
  if ( v4 )
  {
    (*(void (__cdecl **)(int, int, int))(unk_0 + 188))(v4, a2, a1);
    v2 = v4;
  }
  return v2;
}

//----- (0000A90D) --------------------------------------------------------
int __cdecl sub_A90D(int a1, int a2)
{
  int v2; // ecx@1
  int v4; // [sp+1Ch] [bp-1Ch]@1

  v4 = 0;
  (*(void (__cdecl **)(signed int, int, int *))(unk_0 + 44))(6, a1, &v4);
  v2 = v4;
  if ( v4 )
  {
    (*(void (__cdecl **)(int, int, int))(unk_0 + 188))(v4, a2, a1);
    v2 = v4;
  }
  return v2;
}

//----- (0000AA03) --------------------------------------------------------
int __cdecl sub_AA03(int a1)
{
  int v1; // esi@1
  int v3; // [sp+1Ch] [bp-1Ch]@1

  v3 = 0;
  (*(void (__cdecl **)(signed int, int, int *))(unk_0 + 44))(4, a1, &v3);
  v1 = v3;
  if ( v3 )
    (*(void (__cdecl **)(int, int, _DWORD))(unk_0 + 192))(v3, a1, 0);
  return v1;
}

//----- (0000AA70) --------------------------------------------------------
int __cdecl sub_AA70(int a1, unsigned int a2, int a3, unsigned int *a4)
{
  int v4; // edi@1
  int v5; // esi@1
  __int16 v6; // dx@5
  int v7; // edx@8
  unsigned int *v8; // edx@14
  unsigned int *v9; // edx@23
  unsigned int v10; // eax@23
  unsigned int v11; // edx@23
  unsigned int *v12; // edx@24
  int v13; // ecx@25
  int v14; // esi@25
  char *i; // edx@25
  unsigned int *v16; // edx@31
  int v17; // eax@31
  int v18; // edx@31
  int *v19; // edx@32
  int v20; // eax@33
  char *j; // edx@33
  unsigned int *v22; // eax@38
  unsigned int v23; // eax@38
  char v24; // zf@38
  unsigned int v25; // eax@38
  int v26; // esi@40
  int v27; // edx@40
  int v28; // eax@43
  unsigned int *v29; // eax@50
  char *v30; // eax@50
  char *v31; // eax@50
  int v32; // esi@52
  int v33; // edx@52
  int v34; // eax@55
  unsigned int *v35; // eax@62
  unsigned int v36; // ecx@62
  unsigned int *v37; // edx@63
  unsigned int v38; // edx@63
  int v39; // ST34_4@64
  int v40; // ST30_4@64
  int v41; // ST2C_4@64
  int v42; // ST28_4@64
  int v43; // ST24_4@64
  int v44; // ST20_4@64
  int v45; // ST1C_4@64
  int v46; // ST18_4@64
  int v47; // ST14_4@64
  int v48; // ST10_4@64
  int v49; // ST04_4@64
  unsigned int v50; // esi@64
  int v51; // eax@64
  unsigned int *v52; // edx@65
  unsigned int v53; // edx@65
  int v54; // ST1C_4@65
  int v55; // ST18_4@65
  int v56; // ST14_4@65
  int v57; // ST10_4@65
  unsigned int *v58; // edx@66
  unsigned int v59; // eax@66
  char *v60; // edx@66
  unsigned int v62; // [sp+5Ch] [bp-8Ch]@7
  __int16 v63; // [sp+72h] [bp-76h]@42
  int v64; // [sp+74h] [bp-74h]@106
  char v65; // [sp+7Bh] [bp-6Dh]@54
  char *v66; // [sp+7Ch] [bp-6Ch]@50
  unsigned int v67; // [sp+80h] [bp-68h]@38
  unsigned int v68; // [sp+84h] [bp-64h]@7
  unsigned int v69; // [sp+88h] [bp-60h]@1
  unsigned int v70; // [sp+8Ch] [bp-5Ch]@1
  char v71; // [sp+94h] [bp-54h]@25
  signed int v72; // [sp+D8h] [bp-10h]@1

  v72 = 43643;
  v4 = a3;
  v5 = a2;
  v70 = 0;
  v69 = a2 >> 1;
  while ( 1 )
  {
    v6 = *(_WORD *)v4;
    if ( !*(_WORD *)v4 )
      break;
    v64 = v69 - 1;
    if ( v70 >= v69 - 1 )
      break;
    if ( v6 == 37 )
    {
      v62 = 0;
      v68 = 0;
      while ( 2 )
      {
        v4 += 2;
        v7 = *(_WORD *)v4;
        switch ( v7 )
        {
          case 45:
            v62 |= 1u;
            continue;
          case 43:
            v62 |= 2u;
            continue;
          case 32:
            v62 |= 4u;
            continue;
          case 44:
            v62 |= 8u;
            continue;
          case 76:
          case 108:
            v62 |= 0x10u;
            continue;
          case 42:
            v8 = a4;
            ++a4;
            v68 = *v8;
            continue;
          case 48:
            v62 |= 0x20u;
            goto LABEL_16;
          case 49:
          case 50:
          case 51:
          case 52:
          case 53:
          case 54:
          case 55:
          case 56:
          case 57:
LABEL_16:
            v68 = 0;
            while ( 1 )
            {
              v4 += 2;
              v68 = v7 + 10 * v68 - 48;
              LOWORD(v7) = *(_WORD *)v4;
              if ( (unsigned __int16)(*(_WORD *)v4 - 48) > 9u )
                break;
              v7 = (unsigned __int16)v7;
            }
            v4 -= 2;
            continue;
          default:
            switch ( *(_WORD *)v4 )
            {
              case 0x58:
                LOBYTE(v62) = v62 | 0x20;
                v68 = 16;
                goto LABEL_22;
              case 0x78:
LABEL_22:
                if ( v62 & 0x10 )
                {
                  v9 = a4;
                  a4 += 2;
                  v10 = *v9;
                  v11 = v9[1];
                }
                else
                {
                  v12 = a4;
                  ++a4;
                  v10 = *v12;
                  v11 = 0;
                }
                sub_BC21((int)&v71, v10, v11, v62, v68);
                v13 = v70;
                v14 = a1 + 2 * v70;
                for ( i = &v71; *(_WORD *)i; i += 2 )
                {
                  v14 += 2;
                  if ( v13 == v64 )
                    break;
                  *(_WORD *)(v14 - 2) = *(_WORD *)i;
                  ++v13;
                }
                goto LABEL_103;
              case 0x64:
                if ( v62 & 0x10 )
                {
                  v16 = a4;
                  a4 += 2;
                  v17 = *v16;
                  v18 = v16[1];
                }
                else
                {
                  v19 = (int *)a4;
                  ++a4;
                  v17 = *v19;
                  v18 = 0;
                }
                sub_BCF9((int)&v71, v17, v18, v62, v68);
                v20 = a1 + 2 * v70;
                v13 = v70;
                for ( j = &v71; *(_WORD *)j; j += 2 )
                {
                  v20 += 2;
                  if ( v13 == v64 )
                    break;
                  *(_WORD *)(v20 - 2) = *(_WORD *)j;
                  ++v13;
                }
                goto LABEL_103;
              case 0x53:
              case 0x73:
                v22 = a4;
                ++a4;
                v23 = *v22;
                v67 = v23;
                v24 = v23 == 0;
                v25 = (unsigned int)L"oller\n";
                if ( !v24 )
                  v25 = v67;
                v26 = a1 + 2 * v70;
                v27 = 0;
                while ( 1 )
                {
                  v13 = v27 + v70;
                  v63 = *(_WORD *)(v25 + 2 * v27);
                  if ( !*(_WORD *)(v25 + 2 * v27) )
                    break;
                  v26 += 2;
                  if ( v27 == v64 - v70 )
                    break;
                  ++v27;
                  *(_WORD *)(v26 - 2) = v63;
                }
                v28 = a1 + 2 * v13;
                while ( v27 < v68 )
                {
                  v28 += 2;
                  if ( v64 <= (unsigned int)v13 )
                    break;
                  *(_WORD *)(v28 - 2) = 32;
                  ++v13;
                  ++v27;
                }
                goto LABEL_103;
              case 0x61:
                v29 = a4;
                ++a4;
                v30 = (char *)*v29;
                v66 = v30;
                v24 = v30 == 0;
                v31 = "/No Device";
                if ( !v24 )
                  v31 = v66;
                v32 = a1 + 2 * v70;
                v33 = 0;
                while ( 1 )
                {
                  v13 = v33 + v70;
                  v65 = v31[v33];
                  if ( !v31[v33] )
                    break;
                  v32 += 2;
                  if ( v33 == v64 - v70 )
                    break;
                  ++v33;
                  *(_WORD *)(v32 - 2) = (unsigned __int8)v65;
                }
                v34 = a1 + 2 * v13;
                while ( v33 < v68 )
                {
                  v34 += 2;
                  if ( v64 <= (unsigned int)v13 )
                    break;
                  *(_WORD *)(v34 - 2) = 32;
                  ++v13;
                  ++v33;
                }
                goto LABEL_103;
              case 0x63:
                v35 = a4;
                ++a4;
                *(_WORD *)(a1 + 2 * v70) = *v35;
                v36 = v70;
                break;
              case 0x67:
                v37 = a4;
                v13 = v70;
                ++a4;
                v38 = *v37;
                if ( !v38 )
                  goto LABEL_103;
                v39 = *(_BYTE *)(v38 + 15);
                v40 = *(_BYTE *)(v38 + 14);
                v41 = *(_BYTE *)(v38 + 13);
                v42 = *(_BYTE *)(v38 + 12);
                v43 = *(_BYTE *)(v38 + 11);
                v44 = *(_BYTE *)(v38 + 10);
                v45 = *(_BYTE *)(v38 + 9);
                v46 = *(_BYTE *)(v38 + 8);
                v47 = *(_WORD *)(v38 + 6);
                v48 = *(_WORD *)(v38 + 4);
                v49 = v5;
                v50 = v70;
                v51 = sub_B3BF(a1 + 2 * v70, v49, (int)L"ogrammable Interrupt Controller\n", *(_DWORD *)v38);
                goto LABEL_99;
              case 0x74:
                v52 = a4;
                ++a4;
                v53 = *v52;
                v54 = *(_BYTE *)(v53 + 5);
                v55 = *(_BYTE *)(v53 + 4);
                v56 = *(_WORD *)v53;
                v57 = *(_BYTE *)(v53 + 3);
                v13 = sub_B3BF(
                        a1 + 2 * v70,
                        v5,
                        (int)L"\u7200\u6f00\u6700\u7200\u6100\u6d00\u6d00\u6100\u6200\u6c00\u6500\u2000\u4900\u6e00\u7400\u6500\u7200\u7200\u7500\u7000\u7400\u2000\u4300\u6f00\u6e00\u7400\u7200\u6f00\u6c00\u6c00\u6500\u7200\u0a00",
                        *(_BYTE *)(v53 + 2))
                    + v70
                    - 1;
                goto LABEL_103;
              case 0x72:
                v58 = a4;
                ++a4;
                v59 = *v58;
                v60 = byte_CB71;
                if ( !v59 )
                  goto LABEL_96;
                v60 = byte_CB79;
                if ( v59 == -2147483647 )
                  goto LABEL_96;
                v60 = (char *)dword_CB84;
                if ( v59 == -2147483646 )
                  goto LABEL_96;
                v60 = " number: %s (size: %d)\n";
                if ( v59 == -2147483645 )
                  goto LABEL_96;
                v60 = "(size: %d)\n";
                if ( v59 == -2147483644 )
                  goto LABEL_96;
                v60 = "lid char %c\n";
                if ( v59 == -2147483643 )
                  goto LABEL_96;
                v60 = "alid checksum: %d  (modulo 34 is %d)\n";
                if ( v59 == -2147483642 )
                  goto LABEL_96;
                v60 = "sum: %d  (modulo 34 is %d)\n";
                if ( v59 == -2147483641 )
                  goto LABEL_96;
                v60 = "ulo 34 is %d)\n";
                if ( v59 == -2147483640 )
                  goto LABEL_96;
                v60 = "nvalid size %d\n";
                if ( v59 == -2147483639 )
                  goto LABEL_96;
                v60 = &byte_CBFB;
                if ( v59 == -2147483638 )
                  goto LABEL_96;
                v60 = " number: all letters have the same char (%c)\n";
                if ( v59 == -2147483637 )
                  goto LABEL_96;
                v60 = " letters have the same char (%c)\n";
                if ( v59 == -2147483636 )
                  goto LABEL_96;
                v60 = "have the same char (%c)\n";
                if ( v59 == -2147483635 )
                  goto LABEL_96;
                v60 = "char (%c)\n";
                if ( v59 == -2147483634 )
                  goto LABEL_96;
                v60 = "";
                if ( v59 == -2147483633 )
                  goto LABEL_96;
                v60 = "000000";
                if ( v59 == -2147483632 )
                  goto LABEL_96;
                v60 = "%02d_%02d-%02d_%02d_%02d";
                if ( v59 == -2147483631 )
                  goto LABEL_96;
                v60 = "02d_%02d_%02d";
                if ( v59 == -2147483630 )
                  goto LABEL_96;
                v60 = "%02d";
                if ( v59 == -2147483629 )
                  goto LABEL_96;
                v60 = "d%02d%02d%02d%02d";
                if ( v59 == -2147483628 )
                  goto LABEL_96;
                v60 = "d";
                if ( v59 == -2147483627 )
                  goto LABEL_96;
                v60 = " unload driver it has an invalid FilePath\n";
                if ( v59 == -2147483626 )
                  goto LABEL_96;
                v60 = "ver it has an invalid FilePath\n";
                if ( v59 == -2147483625 )
                  goto LABEL_96;
                v60 = "an invalid FilePath\n";
                if ( v59 == -2147483624 )
                  goto LABEL_96;
                v60 = "Path\n";
                if ( v59 == 1 )
                  goto LABEL_96;
                v60 = (char *)dword_CCC4;
                if ( v59 == 2 )
                  goto LABEL_96;
                v60 = (char *)&unk_CCDB;
                if ( v59 == 3 )
                  goto LABEL_96;
                if ( v59 == 4 )
                {
                  v60 = "iver it has an invalid FilePath\n";
LABEL_96:
                  v51 = sub_B3BF(a1 + 2 * v70, v5, (int)L"neric 8237 DMA controller\n", (char)v60);
                }
                else
                {
                  v51 = sub_B3BF(a1 + 2 * v70, v5, (int)&aNeric8237DmaCo[3], v59);
                }
                v50 = v70;
LABEL_99:
                v13 = v51 + v50 - 1;
                goto LABEL_103;
              case 0x25:
                v36 = v70;
                *(_WORD *)(a1 + 2 * v70) = 37;
                break;
              default:
                *(_WORD *)(a1 + 2 * v70) = *(_WORD *)v4;
                v36 = v70;
                break;
            }
            v13 = v36 + 1;
LABEL_103:
            v70 = v13;
            v5 = a2 - 2 * v13;
            break;
        }
        break;
      }
    }
    else
    {
      if ( v6 == 10 && v70 < v69 - 2 )
      {
        v5 -= 2;
        *(_WORD *)(a1 + 2 * v70++) = 13;
        v6 = *(_WORD *)v4;
      }
      v5 -= 2;
      *(_WORD *)(a1 + 2 * v70++) = v6;
    }
    v4 += 2;
  }
  *(_WORD *)(a1 + 2 * v70) = 0;
  return (signed int)(2 * v70 + 2) >> 1;
}
// CB84: using guessed type int dword_CB84[4];
// CBFB: using guessed type char byte_CBFB;
// CCC4: using guessed type int dword_CCC4[5];
// EA88: using guessed type __int16 aOller[7];
// EAA4: using guessed type __int16 aOgrammableInte[33];
// EAEC: using guessed type __int16 aSaProgrammable[38];
// EB3C: using guessed type __int16 aNeric8237DmaCo[27];

//----- (0000B3BF) --------------------------------------------------------
int __cdecl sub_B3BF(int a1, int a2, int a3, char a4)
{
  return sub_AA70(a1, a2, a3, (unsigned int *)&a4);
}

//----- (0000B563) --------------------------------------------------------
int __cdecl sub_B563(int a1, char a2)
{
  int v2; // esi@1
  int v3; // eax@1
  char v5; // [sp+1Ch] [bp-29Ch]@1
  char *v6; // [sp+29Ch] [bp-1Ch]@1

  v6 = &a2;
  v2 = sub_AA70((int)&v5, 0x280u, a1, (unsigned int *)&a2);
  v3 = *(_DWORD *)(unk_0 + 44);
  if ( v3 )
    (*(void (__cdecl **)(int, char *))(v3 + 4))(v3, &v5);
  return v2;
}

//----- (0000B631) --------------------------------------------------------
signed int __cdecl sub_B631(int a1, int a2)
{
  signed int v2; // edx@1

  v2 = 1;
  do
  {
    if ( *(_BYTE *)(a1 + v2 - 1) != *(_BYTE *)(a2 + v2 - 1) )
      return 0;
    ++v2;
  }
  while ( v2 != 17 );
  return 1;
}

//----- (0000B65D) --------------------------------------------------------
int __cdecl sub_B65D(int a1, int a2)
{
  int v2; // ecx@1
  int v3; // edx@1
  int result; // eax@3

  v2 = a1;
  v3 = a2;
  while ( 1 )
  {
    result = *(_WORD *)v3;
    if ( !(_WORD)result )
      break;
    *(_WORD *)v2 = result;
    v3 += 2;
    v2 += 2;
  }
  *(_WORD *)v2 = 0;
  return result;
}

//----- (0000B680) --------------------------------------------------------
int __cdecl sub_B680(int a1)
{
  int result; // eax@1

  for ( result = 0; *(_WORD *)(a1 + 2 * result); ++result )
    ;
  return result;
}

//----- (0000B694) --------------------------------------------------------
int __cdecl sub_B694(unsigned __int16 *a1, int a2)
{
  unsigned __int16 *v2; // edx@1
  int i; // ecx@1
  unsigned __int16 v4; // ax@4

  v2 = a1;
  for ( i = a2; ; i += 2 )
  {
    v4 = *v2;
    if ( !*v2 || v4 != *(_WORD *)i )
      break;
    ++v2;
  }
  return v4 - *(_WORD *)i;
}

//----- (0000B708) --------------------------------------------------------
int __cdecl sub_B708(int a1)
{
  int result; // eax@1

  for ( result = 0; *(_BYTE *)(result + a1); ++result )
    ;
  return result;
}

//----- (0000B71B) --------------------------------------------------------
int __cdecl sub_B71B(int a1, int a2)
{
  int v2; // eax@1
  int i; // ecx@1

  v2 = a1;
  for ( i = a2; *(_BYTE *)i; *(_BYTE *)v2++ = *(_BYTE *)i++ )
    ;
  *(_BYTE *)v2 = 0;
  return v2 + 1;
}

//----- (0000B8EA) --------------------------------------------------------
int __cdecl sub_B8EA(int a1)
{
  int i; // eax@1

  for ( i = 0; *(_WORD *)(a1 + 2 * i); ++i )
    ;
  return 2 * i + 2;
}

//----- (0000BACB) --------------------------------------------------------
int __cdecl sub_BACB(int a1, int a2)
{
  int v2; // eax@1
  int v3; // ecx@1
  int i; // edx@4
  int result; // eax@6

  v2 = 0;
  v3 = a2;
  while ( *(_WORD *)(a1 + 2 * v2) )
    ++v2;
  for ( i = a1 + 2 * v2; ; i += 2 )
  {
    result = *(_WORD *)v3;
    if ( !(_WORD)result )
      break;
    *(_WORD *)i = result;
    v3 += 2;
  }
  *(_WORD *)i = 0;
  return result;
}

//----- (0000BC21) --------------------------------------------------------
int __cdecl sub_BC21(int a1, unsigned int a2, unsigned int a3, char a4, unsigned int a5)
{
  signed int v5; // eax@1
  unsigned int v6; // edx@1
  unsigned int v7; // esi@3
  unsigned int v8; // ecx@3
  unsigned __int64 v9; // rax@4
  unsigned __int64 v10; // kr08_8@4
  char *v11; // ecx@5
  unsigned int v12; // eax@5
  signed int v13; // edx@5
  int v14; // edx@12
  int result; // eax@15
  char *v16; // [sp+1Ch] [bp-5Ch]@3
  char v17[84]; // [sp+24h] [bp-54h]@4
  signed int v18; // [sp+68h] [bp-10h]@1
  unsigned int v19; // [sp+90h] [bp+18h]@3

  v5 = 29;
  v18 = 48177;
  v6 = a2;
  if ( a5 < 0x1E )
    v5 = a5;
  v7 = 0;
  v8 = a3;
  v19 = v5;
  v16 = (char *)&dword_F010[-12044] + v18 - 1;
  do
  {
    *(_WORD *)&v17[2 * v7++] = *(_WORD *)&v16[2 * (v6 & 0xF)];
    v9 = sub_BEC7(__PAIR__(v8, v6), 4);
    v10 = v9;
    v8 = v10 >> 32;
    v6 = v10;
  }
  while ( __PAIR__(v8, (unsigned int)v9) );
  v11 = &v17[2 * v7];
  v12 = v7;
  v13 = (a4 & 0x20u) < 1 ? 32 : 48;
  if ( !(a4 & 1) )
  {
    while ( v12 < v19 )
    {
      *(_WORD *)v11 = v13;
      ++v12;
      v11 += 2;
    }
  }
  if ( v19 && (v11 - v17) >> 1 > v19 )
    v11 = &v17[2 * v19];
  v14 = 0;
  while ( v17 != v11 )
  {
    v11 -= 2;
    *(_WORD *)(a1 + 2 * v14++) = *(_WORD *)v11;
  }
  result = v14;
  *(_WORD *)(a1 + 2 * v14) = 0;
  return result;
}
// F010: using guessed type int dword_F010[48];
// BC21: using guessed type char var_54[84];

//----- (0000BCF9) --------------------------------------------------------
int __cdecl sub_BCF9(int a1, int a2, int a3, unsigned int a4, unsigned int a5)
{
  signed int v5; // eax@1
  char *v6; // ecx@6
  int v7; // eax@13
  int v8; // edx@20
  unsigned __int64 v10; // [sp+20h] [bp-68h]@1
  char *v11; // [sp+28h] [bp-60h]@5
  int v12; // [sp+2Ch] [bp-5Ch]@5
  unsigned int v13; // [sp+30h] [bp-58h]@5
  char v14; // [sp+37h] [bp-51h]@1
  int v15; // [sp+3Ch] [bp-4Ch]@6
  char v16[60]; // [sp+40h] [bp-48h]@5
  __int16 v17; // [sp+7Ch] [bp-Ch]@6
  unsigned int v18; // [sp+A0h] [bp+18h]@3

  v14 = 0;
  LODWORD(v10) = a2;
  v5 = 29;
  if ( a5 < 0x1E )
    v5 = a5;
  HIDWORD(v10) = a3;
  v18 = v5;
  if ( a3 < 0 )
  {
    v10 = -(signed __int64)v10;
    v14 = 1;
  }
  v11 = v16;
  v12 = 0;
  v13 = 0;
  while ( 1 )
  {
    v10 = sub_BEE3(v10, 0xAu, (int)&v17);
    *(_WORD *)v11 = v17 + 48;
    v6 = v11 + 2;
    ++v13;
    v15 = v12 + 1;
    if ( (a4 >> 3) & 1 && (v13 == 3 * (v13 / 3)) & (__PAIR__(v10, HIDWORD(v10)) != 0) )
    {
      *((_WORD *)v11 + 1) = 44;
      v6 = v11 + 4;
      v15 = v12 + 2;
    }
    if ( !__PAIR__(v10, HIDWORD(v10)) )
      break;
    v11 = v6;
    v12 = v15;
  }
  if ( v14 )
  {
    *(_WORD *)v6 = 45;
    v6 += 2;
    ++v15;
  }
  v7 = v15;
  if ( !(a4 & 1) )
  {
    while ( v18 > v7 )
    {
      *(_WORD *)v6 = ((a4 >> 5) & (unsigned __int8)(v14 ^ 1)) < 1 ? 32 : 48;
      ++v7;
      v6 += 2;
    }
  }
  if ( v18 && v18 < (v6 - v16) >> 1 )
    v6 = &v16[2 * v18];
  v8 = 0;
  while ( v16 != v6 )
  {
    v6 -= 2;
    *(_WORD *)(a1 + 2 * v8++) = *(_WORD *)v6;
  }
  *(_WORD *)(a1 + 2 * v8) = 0;
  return v8;
}
// BCF9: using guessed type char var_48[60];

//----- (0000BEC7) --------------------------------------------------------
unsigned __int64 __cdecl sub_BEC7(unsigned __int64 a1, char a2)
{
  return a1 >> a2;
}

//----- (0000BEE3) --------------------------------------------------------
unsigned __int64 __cdecl sub_BEE3(unsigned __int64 a1, unsigned int a2, int a3)
{
  unsigned int v3; // esi@2

  if ( a3 )
  {
    v3 = a2;
    *(_DWORD *)a3 = sub_C120(a1, a2);
  }
  else
  {
    v3 = a2;
  }
  return sub_BFD0(a1, v3, 0);
}

//----- (0000BFD0) --------------------------------------------------------
unsigned __int64 __cdecl sub_BFD0(unsigned __int64 a1, unsigned int a2, unsigned int a3)
{
  unsigned int v3; // ecx@1
  signed int v5; // ecx@3
  unsigned __int64 result; // rax@4
  int v12; // edi@7
  unsigned __int64 v13; // rtt@7
  signed int v14; // edi@7
  unsigned __int64 v15; // rax@7
  unsigned __int64 v16; // rtt@11
  unsigned int v17; // [sp+4h] [bp-24h]@7
  char v18; // [sp+18h] [bp-10h]@6

  v3 = a2;
  _EDI = a3;
  if ( a3 )
  {
    if ( a3 <= HIDWORD(a1) )
    {
      __asm { bsr     eax, edi }
      v18 = _EAX ^ 0x1F;
      if ( _EAX ^ 0x1F )
      {
        v12 = (a2 >> (32 - v18)) | (a3 << v18);
        LODWORD(v13) = ((unsigned int)a1 >> (32 - v18)) | (HIDWORD(a1) << v18);
        HIDWORD(v13) = HIDWORD(a1) >> (32 - v18);
        v17 = v13 % (unsigned int)v12;
        v14 = v13 / (unsigned int)v12;
        v15 = (a2 << v18) * (unsigned __int64)(unsigned int)v14;
        if ( v17 >= HIDWORD(v15) )
        {
          v5 = v14;
          if ( v17 != HIDWORD(v15) || (_DWORD)a1 << v18 >= (unsigned int)v15 )
            return (unsigned int)v5;
        }
        return (unsigned int)(v14 - 1);
      }
      v5 = 1;
      if ( a2 <= (unsigned int)a1 || a3 < HIDWORD(a1) )
        return (unsigned int)v5;
    }
    return 0i64;
  }
  if ( a2 > HIDWORD(a1) )
  {
    v5 = a1 / a2;
    return (unsigned int)v5;
  }
  if ( !a2 )
    v3 = 1 / 0u;
  LODWORD(v16) = a1;
  HIDWORD(v16) = HIDWORD(a1) % v3;
  HIDWORD(result) = HIDWORD(a1) / v3;
  LODWORD(result) = v16 / v3;
  return result;
}

//----- (0000C120) --------------------------------------------------------
int __cdecl sub_C120(unsigned __int64 a1, __int64 a2)
{
  unsigned int v2; // ecx@1
  unsigned __int64 v3; // rtt@4
  int result; // eax@4
  unsigned __int64 v10; // rtt@13
  unsigned __int64 v11; // rax@13
  unsigned int v12; // ecx@13
  unsigned int v13; // esi@13
  int v14; // [sp+8h] [bp-28h]@1
  char v15; // [sp+14h] [bp-1Ch]@7
  unsigned int v16; // [sp+18h] [bp-18h]@13
  int v17; // [sp+1Ch] [bp-14h]@1
  unsigned int v18; // [sp+20h] [bp-10h]@13
  unsigned int v19; // [sp+24h] [bp-Ch]@13

  v14 = HIDWORD(a2);
  v2 = a2;
  v17 = a1;
  if ( HIDWORD(a2) )
  {
    result = a1;
    if ( HIDWORD(a2) <= HIDWORD(a1) )
    {
      __asm { bsr     eax, dword ptr [ebp+var_2C+4] }
      v15 = _EAX ^ 0x1F;
      if ( _EAX ^ 0x1F )
      {
        v19 = ((unsigned int)a2 >> (32 - v15)) | (HIDWORD(a2) << v15);
        v18 = (_DWORD)a1 << v15;
        LODWORD(v10) = ((unsigned int)a1 >> (32 - v15)) | (HIDWORD(a1) << v15);
        HIDWORD(v10) = HIDWORD(a1) >> (32 - v15);
        v16 = v10 % v19;
        v11 = ((_DWORD)a2 << v15) * (unsigned __int64)(unsigned int)(v10 / v19);
        v12 = HIDWORD(v11);
        v13 = ((_DWORD)a2 << v15) * (v10 / v19);
        if ( v16 < HIDWORD(v11) || v16 == HIDWORD(v11) && v18 < (unsigned int)v11 )
        {
          v12 = (__PAIR__(HIDWORD(v11), v13) - __PAIR__(v19, (_DWORD)a2 << v15)) >> 32;
          v13 -= (_DWORD)a2 << v15;
        }
        result = ((__PAIR__(v16, v18) - __PAIR__(v12, v13)) >> 32 << (32 - v15)) | ((v18 - v13) >> v15);
      }
      else
      {
        if ( (unsigned int)a2 <= (unsigned int)a1 || HIDWORD(a2) < HIDWORD(a1) )
          v17 = a1 - a2;
        result = v17;
      }
    }
  }
  else if ( (unsigned int)a2 > HIDWORD(a1) )
  {
    result = a1 % (unsigned int)a2;
  }
  else
  {
    if ( !(_DWORD)a2 )
      v2 = 1 / 0u;
    LODWORD(v3) = a1;
    HIDWORD(v3) = __PAIR__(HIDWORD(a2), HIDWORD(a1)) % v2;
    result = v3 % v2;
  }
  return result;
}

//----- (00012590) --------------------------------------------------------
int __fastcall sub_12590(int a1, int a2)
{
  int v3; // et1@2
  int v5; // et1@3
  int v7; // [sp+68h] [bp-8h]@3

  if ( (unsigned int)(a2 - 1) <= 7 )
  {
    _EDX = 4 * (a2 - 2);
    v3 = *(int *)((char *)&off_15 + _EDX + 1);
    __asm { arpl    ax, dx }
    JUMPOUT(__CS__, &byte_9[_EDX - 1]);
  }
  v5 = *(_DWORD *)(a1 + 24);
  ((void (__fastcall *)(int, signed int))(a1 + 1))(a1 + 1, 1296843359);
  if ( v7 - 1 >= 0 )
    sub_173E1(1296843359);
  else
    sub_17431((char *)0x4D4C425F);
  return v7;
}
// 15: using guessed type int (*off_15)[6];

//----- (00014282) --------------------------------------------------------
int __usercall sub_14282@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebp>)
{
  int v4; // et1@1
  int v5; // eax@1
  int v6; // et1@4
  unsigned int v7; // ecx@4
  int v8; // eax@4
  int v9; // et1@5
  unsigned int v10; // ecx@5
  int v11; // eax@5
  int v12; // et1@7
  unsigned int v13; // ecx@7
  int v14; // eax@7
  int v15; // et1@9
  unsigned int v16; // ecx@9
  int v17; // eax@9
  int v18; // et1@10
  int v19; // et1@10
  int v20; // edx@10
  int v21; // eax@10

  *(_DWORD *)(a4 + 16) = a3;
  *(_DWORD *)(a4 + 24) = a2;
  *(_DWORD *)(a4 + 32) = a1 - 3;
  *(_DWORD *)(a4 + 40) = a3;
  *(_DWORD *)(a4 - 16) = ((int (__fastcall *)(_DWORD))(*(_DWORD *)(*(int *)((char *)&dword_10000[282] + 3) - 1) - 1))(*(int *)((char *)&dword_10000[280] + 1));
  v4 = *(_DWORD *)(*(int *)((char *)&dword_10000[277] + 1) + 8);
  v5 = *(_DWORD *)(a4 - 16) - 2;
  *(_DWORD *)(a4 - 24) = ((int (__fastcall *)(_DWORD))(a4 - 288))(0) - 1;
  if ( *(_DWORD *)(a4 - 24) - 1 >= 0 )
  {
    *(_DWORD *)(a4 - 8) = (*(_BYTE *)(a4 - 214) << 16)
                        + (*(_BYTE *)(a4 - 215) << 8)
                        + *(_BYTE *)(a4 - 216)
                        + (*(_BYTE *)(a4 - 213) << 24);
    *(_DWORD *)(a4 - 12) = (*(_BYTE *)(a4 - 210) << 16)
                         + (*(_BYTE *)(a4 - 211) << 8)
                         + *(_BYTE *)(a4 - 212)
                         + (*(_BYTE *)(a4 - 209) << 24);
    *(_DWORD *)(a4 - 4) = (*(_BYTE *)(a4 - 218) << 16)
                        + (*(_BYTE *)(a4 - 219) << 8)
                        + *(_BYTE *)(a4 - 220)
                        + (*(_BYTE *)(a4 - 217) << 24);
    if ( *(_DWORD *)(a4 + 40) )
    {
      v6 = *(_DWORD *)(a4 + 24);
      v7 = **(_DWORD **)(a4 + 32);
      *(_DWORD *)(a4 - 324) = -2139062143;
      *(_DWORD *)(a4 - 304) = (unsigned int)(v7 * (unsigned __int64)*(_DWORD *)(a4 - 324) >> 32) >> 7;
      v8 = 255 * *(_DWORD *)(a4 - 304);
      *(_DWORD *)(a4 - 304) = v7 - v8;
      *(_BYTE *)(a4 - 288 + v8) = *(_BYTE *)(a4 - 304);
      if ( *(_DWORD *)(a4 + 40) > 1u )
      {
        v9 = *(_DWORD *)(a4 + 24);
        v10 = **(_DWORD **)(a4 + 32) >> 8;
        *(_DWORD *)(a4 - 324) = -2139062143;
        *(_DWORD *)(a4 - 300) = (unsigned int)(v10 * (unsigned __int64)*(_DWORD *)(a4 - 324) >> 32) >> 7;
        v11 = 255 * *(_DWORD *)(a4 - 300);
        *(_DWORD *)(a4 - 300) = v10 - v11;
        *(_BYTE *)(a4 - 288 + v11) = *(_BYTE *)(a4 - 300);
      }
      if ( *(_DWORD *)(a4 + 40) > 2u )
      {
        v12 = *(_DWORD *)(a4 + 24);
        v13 = **(_DWORD **)(a4 + 32) >> 16;
        *(_DWORD *)(a4 - 324) = -2139062143;
        *(_DWORD *)(a4 - 296) = (unsigned int)(v13 * (unsigned __int64)*(_DWORD *)(a4 - 324) >> 32) >> 7;
        v14 = 255 * *(_DWORD *)(a4 - 296);
        *(_DWORD *)(a4 - 296) = v13 - v14;
        *(_BYTE *)(a4 - 288 + v14) = *(_BYTE *)(a4 - 296);
      }
      if ( *(_DWORD *)(a4 + 40) > 3u )
      {
        v15 = *(_DWORD *)(a4 + 24);
        v16 = **(_DWORD **)(a4 + 32) >> 24;
        *(_DWORD *)(a4 - 324) = -2139062143;
        *(_DWORD *)(a4 - 292) = (unsigned int)(v16 * (unsigned __int64)*(_DWORD *)(a4 - 324) >> 32) >> 7;
        v17 = 255 * *(_DWORD *)(a4 - 292);
        *(_DWORD *)(a4 - 292) = v16 - v17;
        *(_BYTE *)(a4 - 288 + v17) = *(_BYTE *)(a4 - 292);
      }
      v18 = *(_DWORD *)(*(int *)((char *)&dword_10000[121] + 1) + 16);
      v19 = *(_DWORD *)(a4 + 24);
      v20 = *(_DWORD *)(a4 + 24) - 2 + a4 - 288;
      v21 = *(_DWORD *)(a4-- + 24) - 3;
      ((void (__fastcall *)(int))v20)(v21 + 2);
    }
    else
    {
      **(_DWORD **)(a4 + 32) = (*(_BYTE *)(a4 - 288 + *(_DWORD *)(a4 + 24) + 2) << 16)
                             + (*(_BYTE *)(a4 - 288 + *(_DWORD *)(a4 + 24) + 1) << 8)
                             + *(_BYTE *)(a4 - 288 + *(_DWORD *)(a4 + 24))
                             + (*(_BYTE *)(a4 - 288 + *(_DWORD *)(a4 + 24) + 3) << 24);
    }
    *(_DWORD *)(a4 - 312) = *(_DWORD *)(a4 - 24) - 1;
  }
  else
  {
    *(_DWORD *)(a4 - 312) = *(_DWORD *)(a4 - 24) - 1;
  }
  return *(_DWORD *)(a4 - 312);
}
// 10000: using guessed type int dword_10000[640];

//----- (00014DDA) --------------------------------------------------------
// write access to const memory has been detected, the output may be wrong!
int *__fastcall sub_14DDA(int a1)
{
  int *result; // eax@4
  int v3; // [sp+Ch] [bp-14h]@2
  int i; // [sp+1Ch] [bp-4h]@4

  if ( a1 )
    v3 = a1;
  else
    v3 = 5489;
  result = (int *)v3;
  *(int *)((char *)&dword_FA94[97] + 3) = v3;
  for ( i = 1; i <= 623; ++i )
  {
    _EAX = i;
    __asm { arpl    ax, ax }
    dword_FA94[_EAX - 1 + 72] = 1812433253
                              * ((dword_FA94[(signed __int16)(i - 2) - 1 + 89] ^ (*(unsigned int *)((char *)&dword_FA94[(signed __int16)(i - 2) - 1 + 82]
                                                                                                  + 3) >> 30))
                               - 1)
                              + i
                              - 1;
    result = &i;
  }
  dword_FA94[33] = 1;
  return result;
}
// 14DFD: write access to const memory at FC1B has been detected
// 14E7C: write access to const memory at FB18 has been detected
// FA94: using guessed type int dword_FA94[104];

//----- (0001510C) --------------------------------------------------------
bool __fastcall sub_1510C(int a1)
{
  int v1; // eax@2
  int v4; // [sp+6Ch] [bp-24h]@1
  int v5; // [sp+70h] [bp-20h]@1
  int v6; // [sp+74h] [bp-1Ch]@1
  int i; // [sp+78h] [bp-18h]@1
  char v8; // [sp+7Fh] [bp-11h]@2
  int v9; // [sp+80h] [bp-10h]@2
  int v10; // [sp+8Ch] [bp-4h]@4
  int v14; // [sp+A0h] [bp+10h]@1

  v14 = a1;
  v4 = sub_182C1(a1);
  v5 = 34;
  v6 = 0;
  for ( i = 0; i < v4; ++i )
  {
    v8 = *(_BYTE *)(v14 + (signed __int16)(v4 - i - 1) - 1 - 2);
    v1 = sub_17E2E();
    v9 = v1 - 1;
    if ( v1 == 1 )
      return 0;
    v10 = v9 - (_DWORD)&unk_F6B8;
    if ( i & 1 )
      v6 += 3 * v10;
    else
      v6 += v10;
  }
  return v6 % *(int *)((char *)&v4 + 3) == 0;
}
// F6C4: using guessed type int[11];

//----- (0001590E) --------------------------------------------------------
// write access to const memory has been detected, the output may be wrong!
int __usercall sub_1590E@<eax>(int a1@<ecx>, unsigned int a2@<ebx>, int a3@<edi>, int a4@<esi>)
{
  int v4; // et1@1
  int v5; // eax@1
  int v6; // et1@2
  int v7; // eax@2
  int v8; // et1@6
  int v9; // eax@6
  int v10; // eax@24
  int v11; // eax@30
  int v12; // eax@40
  int v13; // et1@43
  int v15; // [sp+0h] [bp-398h]@0
  int v16; // [sp+4h] [bp-394h]@0
  int v17; // [sp+8h] [bp-390h]@0
  __int64 v18; // [sp+Ch] [bp-38Ch]@0
  int v19; // [sp+14h] [bp-384h]@0
  int v20; // [sp+18h] [bp-380h]@0
  int v21; // [sp+50h] [bp-348h]@3
  unsigned int v22; // [sp+54h] [bp-344h]@5
  char v23[256]; // [sp+58h] [bp-340h]@20
  char v24[256]; // [sp+59h] [bp-33Fh]@38
  __int16 v25; // [sp+158h] [bp-240h]@19
  int v26; // [sp+358h] [bp-40h]@4
  int v27; // [sp+360h] [bp-38h]@1
  int v28; // [sp+368h] [bp-30h]@1
  int i; // [sp+370h] [bp-28h]@8
  int j; // [sp+378h] [bp-20h]@20
  char v31; // [sp+37Fh] [bp-19h]@1
  int v32; // [sp+380h] [bp-18h]@30
  int v36; // [sp+3A8h] [bp+10h]@1

  v36 = a1;
  v27 = 0;
  v31 = 0;
  v4 = *(_DWORD *)(*(int *)((char *)&dword_EF40[18] + 3) + 320);
  v5 = ((int (__fastcall *)(char *, _DWORD))((char *)&dword_EF40[3] + 1))((char *)&dword_EF40[3] + 1, 0);
  v28 = v5 - 1;
  if ( v5 != 1 )
  {
    v6 = *(_DWORD *)(*(int *)((char *)&dword_EF40[4] + 2) + 152);
    v7 = ((int (__fastcall *)(int, char *))(v36 + 1))(v36 + 1, (char *)&dword_EFBC[3] + 3);
    v28 = v7 - 1;
    if ( v7 != 1 )
    {
      v21 = v28 - 1;
      return v21 - 1;
    }
    if ( *(_DWORD *)(v26 - 1 + 32) == 1 )
    {
      sub_16F2C(0, v15, v16, v17, v18, SHIDWORD(v18), v19, v20);
      v21 = 2;
      v22 = 2147483648;
      return v21 - 1;
    }
    v8 = *(_DWORD *)(*(_DWORD *)&a8x04x04x02x02x[17] + 152);
    v9 = (*(int (__fastcall **)(_DWORD, char *))(v26 - 1 + 24))(
           *(_DWORD *)(v26 - 1 + 24),
           (char *)&a8x04x04x02x02x[41] + 1);
    v28 = v9 - 1;
    if ( v9 != 1 )
    {
      v21 = v28 - 1;
      return v21 - 1;
    }
    for ( i = v27 - 1;
          (*(_BYTE *)i & 0x7F) != 127 || *(_BYTE *)(i + 1) != -1;
          i = (signed __int16)((*(_BYTE *)(i + 2) | (unsigned __int16)(*(_BYTE *)(i + 3) << 8)) - 1) - 1 + i - 1 - 1 )
    {
      if ( (*(_BYTE *)i & 0x7F) == 3 && (*(_BYTE *)(i + 1) == 11 || *(_BYTE *)(i + 1) == 12) )
      {
        v27 = sub_1B60F(v27, *(_DWORD *)(v26 - 1 + 32)) - 1;
        sub_19600(v27, 0);
        v31 = 1;
        a4 = *(_DWORD *)(*(_DWORD *)((char *)&aRewireIeee1394[17] + 1) - 1 + 88);
        a2 = v27;
        sub_1B38D(v27);
        v28 = ((int (__fastcall *)(char *, _UNKNOWN *))a4)((char *)&loc_97BA + 2, &unk_EDBB) - 1;
        ((void (__fastcall *)(int))(*(_DWORD *)(*(_DWORD *)&aSerialBusContr[21] - 1 + 72) - 1))(v27);
        break;
      }
    }
    if ( !v31 )
    {
      a4 = *(_DWORD *)(*(_DWORD *)&aNtium[0] - 1 + 88);
      a2 = v27;
      sub_1B38D(v27);
      v28 = ((int (__fastcall *)(char *, __int16 *))a4)(
              (char *)&loc_970F + 2,
              L"\u4400\u6f00\u6300\u6b00\u6900\u6e00\u6700\u2000\u5300\u7400\u6100\u7400\u6900\u6f00\u6e00\u7300\u2c00\u2000")
          - 1;
    }
    if ( !v28 )
    {
      if ( sub_19600(*(_DWORD *)(v26 - 1 + 32), (int)&v25) )
      {
        v23[0] = 0;
        v28 = (signed __int16)(sub_164EA((int)((char *)&loc_82CC + 3), (int)sub_7AE2) - 1) - 1;
      }
      else
      {
        sub_17A4E(256, (int)v23, (int)((char *)&v25 + 1), v15, v16, v17, v18);
        for ( j = 0; ; ++j )
        {
          v10 = sub_182C1((int)v23);
          if ( v10 <= j )
            break;
          if ( v23[(signed __int16)(j - 1)] == 92 )
            v23[(signed __int16)(j - 1)] = 47;
        }
        if ( sub_1820F((int)v23, (int)((char *)&loc_83BD + 2))
          && sub_17EEE((int)v23, (int)((char *)&loc_83A9 + 1)) == 1
          && sub_17EEE((int)v23, (int)&loc_8399) == 1
          && v23[sub_182C1((int)v23) - 2] != 47 )
          sub_17D51((int)v23, (int)((char *)&loc_835C + 1));
        v11 = sub_17E56((int)v23, 47);
        v32 = v11 - 1;
        if ( v11 != 1 )
        {
          ++*(_DWORD *)&v31;
          *(_BYTE *)v32 = 0;
        }
        if ( v23[sub_182C1((int)v23) - 2] != 47 )
          sub_17D51((int)v23, (int)((char *)&loc_8304 + 1));
        if ( sub_182C1((int)v23) != 1 )
          v28 = (signed __int16)(sub_164EA((int)((char *)&loc_82E8 + 9), (int)v23) - 1) - 1;
      }
    }
    if ( v31 )
    {
      sub_17D51((int)v23, (int)&loc_82C0);
      sub_179D7(256, (int)&v25, (int)v24, v15, v16, v17, v18);
    }
    else
    {
      v25 = 0;
    }
    v12 = sub_1D32B((int)&v25, (int)((char *)&loc_953F + 2)) - 1;
    if ( !v28 )
      v28 = sub_199DA(
              (int)L"\u4100\u2000\u5000\u7200\u6f00\u6700\u7200\u6100\u6d00\u6d00\u6100\u6200\u6c00\u6500\u2000\u4900\u6e00\u7400\u6500\u7200\u7200\u7500\u7000\u7400\u2000\u4300\u6f00\u6e00\u7400\u7200\u6f00\u6c00\u6c00\u6500\u7200\u0a00",
              (int)&v25,
              (int (__fastcall *)(_DWORD))v36,
              a2,
              a3,
              a4)
          - 1;
    if ( v28 )
    {
      sub_1CCFC(0, v28, (int)((char *)&loc_94FE + 2));
    }
    else
    {
      v13 = *(_DWORD *)(*(_DWORD *)((char *)L"rammable Interrupt Controller\n" + 1) + 320);
      v28 = ((int (__fastcall *)(char *, _DWORD))((char *)&unk_EAE6 + 1))((char *)&unk_EAE6 + 1, 0) - 1;
    }
  }
  if ( *(_DWORD *)((char *)&aOgrammableInte[1] + 1) != 1 )
    *(_DWORD *)((char *)&aNeric8259Progr[33] + 1) = v36 - 1;
  v21 = v28 - 1;
  return v21 - 1;
}
// 15DF1: write access to const memory at EA7F has been detected
// 7AE2: using guessed type int sub_7AE2();
// EA3C: using guessed type __int16 aNeric8259Progr[38];
// EAA4: using guessed type __int16 aOgrammableInte[33];
// EAEC: using guessed type __int16 aSaProgrammable[38];
// ECFC: using guessed type __int16 aDockingStation[22];
// ED70: using guessed type __int16 aNtium[7];
// EDBC: using guessed type __int16 aSerialBusContr[27];
// EDF8: using guessed type __int16 aRewireIeee1394[19];
// EEA8: using guessed type __int16 a8x04x04x02x02x[47];
// EF40: using guessed type int[20];
// EFBC: using guessed type int dword_EFBC[4];
// 1590E: using guessed type char var_340[256];

//----- (00015E60) --------------------------------------------------------
int sub_15E60()
{
  return ((int (*)(void))(*(_DWORD *)(*(_DWORD *)((char *)&aBaseSystemPeri[13] + 1) - 1 + 64) - 2))();
}
// E9FC: using guessed type __int16 aBaseSystemPeri[29];

//----- (00015E87) --------------------------------------------------------
int sub_15E87()
{
  return ((int (*)(void))(*(_DWORD *)(*(_DWORD *)L"\u2000\u7000\u6100\u7200\u6100\u6c00\u6c00\u6500\u6c00\u2000\u7000\u6f00\u7200\u7400\u0a00"
                                    - 1
                                    + 72)
                        - 1))();
}
// E9D0: using guessed type __int16 aP1_xParallelPo[21];

//----- (00015EA6) --------------------------------------------------------
int __fastcall sub_15EA6(int a1, int (__fastcall *a2)(_DWORD))
{
  int v2; // et1@1

  v2 = *(_DWORD *)(*(_DWORD *)&aDirectionalPar[27] + 112);
  return a2(a1 + 1);
}
// E994: using guessed type __int16 aDirectionalPar[28];

//----- (00015F09) --------------------------------------------------------
int sub_15F09()
{
  return ((int (*)(void))(*(_DWORD *)(*(_DWORD *)((char *)&a16550Compatabl[29] + 1) - 1 + 120) - 1))();
}
// E934: using guessed type __int16 a16550Compatabl[30];

//----- (00015F2E) --------------------------------------------------------
int sub_15F2E()
{
  return ((int (*)(void))(*(_DWORD *)(*(_DWORD *)((char *)L"\u3500\u3000\u2000\u6300\u6f00\u6d00\u7000\u6100\u7400\u6100\u6200\u6c00\u6500\u2000\u5300\u6500\u7200\u6900\u6100\u6c00\u2000\u5000\u6f00\u7200\u7400\u0a00"
                                                + 1)
                                    - 1
                                    + 128)
                        - 2))();
}
// E934: using guessed type __int16 a16550Compatabl[30];

//----- (00015F58) --------------------------------------------------------
int sub_15F58()
{
  return ((int (*)(void))(*(_DWORD *)(*(_DWORD *)((char *)&a16450Compatabl[21] + 1) - 1 + 136) - 1))();
}
// E8F8: using guessed type __int16 a16450Compatabl[30];

//----- (00015F7A) --------------------------------------------------------
int __fastcall sub_15F7A(int a1)
{
  int v1; // et1@1

  v1 = *(_DWORD *)(*(_DWORD *)((char *)L"\u5800\u5400\u2000\u6300\u6f00\u6d00\u7000\u6100\u7400\u6100\u6200\u6c00\u6500\u2000\u5300\u6500\u7200\u6900\u6100\u6c00\u2000\u5000\u6f00\u7200\u7400\u0a00"
                             + 1)
                 + 144);
  return ((int (*)(void))(a1 + 1))();
}
// E8B0: using guessed type __int16 aGenericXtCompa[36];

//----- (00015FD3) --------------------------------------------------------
int sub_15FD3()
{
  return ((int (*)(void))(*(_DWORD *)(*(_DWORD *)L"\u2000\u4300\u6f00\u6d00\u6d00\u7500\u6e00\u6900\u6300\u6100\u7400\u6900\u6f00\u6e00\u7300\u2000\u4300\u6f00\u6e00\u7400\u7200\u6f00\u6c00\u6c00\u6500\u7200\u2c00\u2000"
                                    - 1
                                    + 152)
                        - 1))();
}
// E864: using guessed type __int16 aSimpleCommunic[38];

//----- (000161FA) --------------------------------------------------------
int __fastcall sub_161FA(int a1)
{
  int v1; // et1@1

  v1 = *(_DWORD *)(*(_DWORD *)((char *)L"\u6300\u6f00\u6d00\u7000\u6100\u7400\u6100\u6200\u6c00\u6500\u0a00" + 1) + 320);
  return ((int (__fastcall *)(int))(a1 - 3))(a1 + 1);
}
// E668: using guessed type __int16 aACompatable[14];

//----- (000164EA) --------------------------------------------------------
unsigned int __fastcall sub_164EA(int a1, int a2)
{
  int v2; // eax@1
  int v3; // et1@4
  int v4; // eax@4
  int v6; // [sp+0h] [bp-260h]@0
  int v7; // [sp+4h] [bp-25Ch]@0
  int v8; // [sp+8h] [bp-258h]@0
  __int64 v9; // [sp+Ch] [bp-254h]@0
  char v10; // [sp+50h] [bp-210h]@1
  int v11; // [sp+258h] [bp-8h]@2
  int v17; // [sp+278h] [bp+18h]@1

  v17 = a2;
  v2 = sub_179D7(255, (int)&v10, a1, v6, v7, v8, v9) - 1;
  if ( v17 )
    v11 = sub_182C1(v17) - 1;
  else
    v11 = 0;
  v3 = *(_DWORD *)(*(_DWORD *)&aNdleprotocolEr[17] + 88);
  v4 = (*(int (__fastcall **)(int))L": GetVariable: We shouldn't have gotten here error: 0x%x\n")(v11 + 2);
  return ((unsigned int)(v4 - 2) >> 32) | (v4 - 1);
}
// E2A8: using guessed type __int16 aPdatedriverr_0[72];
// E358: using guessed type __int16 aNdleprotocolEr[26];

//----- (00016F2C) --------------------------------------------------------
void __usercall sub_16F2C(char a1@<al>, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
{
  JUMPOUT(__CS__, (char *)&unk_3B + -4 * ((unsigned __int8)(a1 - 2) - 1) + 3);
}

//----- (000173E1) --------------------------------------------------------
int __fastcall sub_173E1(int a1)
{
  return (*(int (__fastcall **)(int))(*(_DWORD *)((char *)&aRifyTheExtende[19] + 1) + 832))(a1 + 1);
}
// D468: using guessed type __int16 aRifyTheExtende[43];

//----- (00017431) --------------------------------------------------------
int __fastcall sub_17431(char *a1)
{
  int v1; // et1@1

  v1 = *(_DWORD *)(*(_DWORD *)((char *)&aRifyEstBitSetT[3] + 1) + 824);
  return ((int (__fastcall *)(char *))a1)(a1 + 1);
}
// D438: using guessed type __int16 aRifyEstBitSetT[22];

//----- (000176AC) --------------------------------------------------------
int __fastcall sub_176AC(char a1)
{
  int v1; // et1@1

  v1 = *(_DWORD *)(*(int *)((char *)&dword_D1AC[5] + 3) - 1 + 8);
  return ((int (__fastcall *)(_DWORD))a1)(a1) - 1;
}
// D1AC: using guessed type int[8];

//----- (000176FE) --------------------------------------------------------
int __fastcall sub_176FE(char a1)
{
  int v1; // et1@1

  v1 = *(_DWORD *)(*(_DWORD *)((char *)&aRifyIctWasRu_0[11] + 1) - 1 + 16);
  return ((int (__fastcall *)(_DWORD))a1)(a1) - 1;
}
// D154: using guessed type __int16 aRifyIctWasRu_0[44];

//----- (00017755) --------------------------------------------------------
int sub_17755()
{
  return (*(int (**)(void))(*(_DWORD *)&aRifyIctWasRunA[9] - 1 + 24))();
}
// D118: using guessed type __int16 aRifyIctWasRunA[28];

//----- (000179D7) --------------------------------------------------------
int __usercall sub_179D7@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4, int a5, int a6, __int64 a7)
{
  int i; // [sp+Ch] [bp-4h]@1
  int v9; // [sp+20h] [bp+10h]@1

  v9 = a3;
  HIDWORD(a7) = a2;
  for ( i = 0; *(_BYTE *)v9 && a1 - 5 > i; ++i )
  {
    *HIDWORD(a7) = *(_BYTE *)v9++;
    *(_DWORD *)((char *)&a7 + 3) += 2;
  }
  if ( a1 - 5 > i )
    *HIDWORD(a7) = 0;
  return a2 - 1;
}

//----- (00017A4E) --------------------------------------------------------
int __usercall sub_17A4E@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4, int a5, int a6, __int64 a7)
{
  int i; // [sp+Ch] [bp-4h]@1
  int v9; // [sp+20h] [bp+10h]@1

  v9 = a3;
  HIDWORD(a7) = a2;
  for ( i = 0; *(_WORD *)v9 && a1 - 5 > i; ++i )
  {
    *HIDWORD(a7) = *(_WORD *)v9;
    v9 += 2;
    ++*(_DWORD *)((char *)&a7 + 3);
  }
  if ( a1 - 5 > i )
    *HIDWORD(a7) = 0;
  return a2 - 1;
}

//----- (00017B43) --------------------------------------------------------
int __fastcall sub_17B43(unsigned __int8 a1)
{
  return ((int (__fastcall *)(_DWORD))(*(_DWORD *)(*(int *)((char *)&dword_CD14[8] + 1) - 1 + 592) - 1))(a1);
}
// CD14: using guessed type int dword_CD14[254];

//----- (00017D51) --------------------------------------------------------
int __fastcall sub_17D51(int a1, int a2)
{
  int v2; // eax@4
  int v4; // [sp+0h] [bp-10h]@1
  int v5; // [sp+4h] [bp-Ch]@1

  v4 = 0;
  v5 = 0;
  while ( *(_BYTE *)(a1 + (signed __int16)(v4 - 1) - 1) )
    ++v4;
  do
  {
    v2 = a1 + (signed __int16)(v4 - 1) - 1;
    *(_BYTE *)v2 = *(_BYTE *)(a2 + (signed __int16)(v5++ - 1) - 1);
    ++v4;
  }
  while ( *(_BYTE *)v2 );
  return a1 - 1;
}

//----- (00017E2E) --------------------------------------------------------
int sub_17E2E()
{
  return ((int (*)(void))(*(_DWORD *)(*(_DWORD *)"ce" - 1 + 1120) - 1))();
}

//----- (00017E56) --------------------------------------------------------
int __fastcall sub_17E56(int a1, char a2)
{
  int v3; // [sp+0h] [bp-30h]@6
  int v4; // [sp+8h] [bp-28h]@8
  _BYTE v5[5]; // [sp+Fh] [bp-21h]@0
  int v6; // [sp+18h] [bp-18h]@1

  *(_DWORD *)&v5[1] = a1 - 3;
  v6 = 0;
  while ( 1 )
  {
    ++*(_DWORD *)v5;
    if ( **(_BYTE **)&v5[1] == 1 )
      break;
    if ( **(_BYTE **)&v5[1] - 2 == (unsigned __int8)(a2 - 1) - 1 )
      v6 = *(_DWORD *)&v5[1] - 1;
  }
  if ( v6 )
  {
    v3 = v6 - 1;
  }
  else
  {
    if ( (unsigned __int8)(a2 - 1) == 1 )
      v4 = *(_DWORD *)&v5[1] - 1;
    else
      v4 = 0;
    v3 = v4 - 1;
  }
  return v3;
}

//----- (00017EEE) --------------------------------------------------------
int __fastcall sub_17EEE(int a1, int a2)
{
  int v3; // [sp+8h] [bp-48h]@3
  _BYTE v4[5]; // [sp+17h] [bp-39h]@0
  _BYTE v5[5]; // [sp+1Fh] [bp-31h]@0
  _BYTE v6[5]; // [sp+3Fh] [bp-11h]@0
  _BYTE v7[5]; // [sp+47h] [bp-9h]@0

  *(_DWORD *)&v4[1] = a1 - 3;
  *(_DWORD *)&v5[1] = a2 - 3;
  if ( a2 && (++*(_DWORD *)v5, **(_BYTE **)&v5[1] != 1) )
  {
    while ( 1 )
    {
      ++*(_DWORD *)v4;
      if ( **(_BYTE **)&v4[1] == 1 )
        break;
      if ( **(_BYTE **)&v4[1] - 2 == **(_BYTE **)&v5[1] - 1 )
      {
        *(_DWORD *)&v6[1] = *(_DWORD *)&v4[1] - 3;
        *(_DWORD *)&v7[1] = *(_DWORD *)&v5[1] - 3;
        do
        {
          ++*(_DWORD *)v6;
          ++*(_DWORD *)v7;
        }
        while ( **(_BYTE **)&v6[1] - 2 == **(_BYTE **)&v7[1] - 1 && **(_BYTE **)&v6[1] != 1 );
        if ( **(_BYTE **)&v7[1] == 1 )
          return *(_DWORD *)&v4[1] - 1;
      }
    }
    v3 = 0;
  }
  else
  {
    v3 = a1 - 1;
  }
  return v3;
}

//----- (000180A8) --------------------------------------------------------
int __fastcall sub_180A8(int a1)
{
  int v1; // et1@1

  v1 = *(_DWORD *)(*(int *)((char *)&dword_C6A4[73] + 3) + 1184);
  return ((int (*)(void))(a1 + 1))();
}
// C6A4: using guessed type int[111];

//----- (000180DE) --------------------------------------------------------
void __usercall sub_180DE(char a1@<al>, int a2, int a3, int a4)
{
  JUMPOUT(__CS__, (char *)&unk_3B + -4 * ((unsigned __int8)(a1 - 3) - 1) + 3);
}

//----- (000181AF) --------------------------------------------------------
int sub_181AF()
{
  return ((int (*)(void))(*(_DWORD *)(dword_C6A4[9] - 1 + 1200) - 2))();
}
// C6A4: using guessed type int dword_C6A4[111];

//----- (0001820F) --------------------------------------------------------
int __fastcall sub_1820F(int a1, int a2)
{
  int savedregs; // [sp+0h] [bp+0h]@2
  int v7; // [sp+10h] [bp+10h]@1

  v7 = a1;
  while ( *(_BYTE *)v7 && *(_BYTE *)v7 == *(_BYTE *)a2 )
  {
    ++v7;
    ++*(int *)((char *)&savedregs + 23);
  }
  return *(_BYTE *)v7 - *(_BYTE *)a2;
}

//----- (000182C1) --------------------------------------------------------
int __fastcall sub_182C1(int a1)
{
  char v1; // al@3
  __int16 i; // [sp+Ch] [bp-4h]@1
  int v7; // [sp+20h] [bp+10h]@1

  v7 = a1;
  for ( i = 0; ; ++i )
  {
    v1 = (*(_BYTE *)v7++ != 0) - 1;
    if ( !v1 )
      break;
  }
  return (signed __int16)(i - 1);
}

//----- (00019028) --------------------------------------------------------
int sub_19028()
{
  int v0; // et1@1
  int v1; // eax@1
  int result; // eax@1
  int v3; // et1@3
  int v4; // et1@3
  int v5; // [sp+50h] [bp-20h]@3
  int v6; // [sp+58h] [bp-18h]@4
  int v7; // [sp+60h] [bp-10h]@1
  int v8; // [sp+67h] [bp-9h]@3
  unsigned int v9; // [sp+68h] [bp-8h]@2

  v0 = *(_DWORD *)(*(_DWORD *)&loc_B886 + 312);
  v1 = ((int (__fastcall *)(signed int))unk_0)(1);
  v7 = v1 - 1;
  result = v1 - 2;
  if ( result >= 0 )
  {
    v9 = 0;
    while ( v9 < v6 - 1 )
    {
      v3 = *(_DWORD *)(*(_DWORD *)&loc_B837 + 264);
      v4 = *(_DWORD *)(8 * (v9 - 1) - 1 + v5 - 1 - 1);
      ((void (__fastcall *)(signed int))unk_0)(3);
      ++v8;
    }
    ((void (__fastcall *)(int))(*(_DWORD *)(*(_DWORD *)&loc_B7EB - 1 + 72) - 1))(v5);
    result = (*(int (**)(void))(*(_DWORD *)((char *)sub_B7E8 - 1) - 1 + 128))() - 1;
  }
  return result;
}
// B7E8: using guessed type int sub_B7E8();

//----- (000190F8) --------------------------------------------------------
int __usercall sub_190F8@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, unsigned int _EBX@<ebx>)
{
  int v4; // et1@6
  int v5; // et1@9
  int v6; // eax@9
  signed int v7; // eax@12
  signed int v9; // eax@19
  int v11; // [sp+0h] [bp-70Ch]@0
  int v12; // [sp+0h] [bp-70Ch]@9
  int v13; // [sp+4h] [bp-708h]@0
  int v14; // [sp+4h] [bp-708h]@9
  int v15; // [sp+8h] [bp-704h]@0
  __int64 v16; // [sp+Ch] [bp-700h]@0
  int v17; // [sp+54h] [bp-6B8h]@3
  unsigned int v18; // [sp+58h] [bp-6B4h]@3
  _BYTE v19[3]; // [sp+5Dh] [bp-6AFh]@11
  __int16 v20[512]; // [sp+25Ch] [bp-4B0h]@4
  __int16 _65B[512]; // [sp+65Bh] [bp-B1h]@7
  char v22[128]; // [sp+65Ch] [bp-B0h]@4
  char v23[128]; // [sp+65Dh] [bp-AFh]@12
  unsigned int v24; // [sp+6DCh] [bp-30h]@6
  int v25; // [sp+6E4h] [bp-28h]@6
  __int64 v26; // [sp+6F0h] [bp-1Ch]@7
  int v30; // [sp+71Ch] [bp+10h]@1
  int v33; // [sp+724h] [bp+18h]@1
  int v36; // [sp+72Ch] [bp+20h]@1

  v30 = a3;
  v33 = a2;
  v36 = a1 - 4;
  if ( a2 && a1 != 4 )
  {
    sub_1CF81((int)v22, (int)((char *)&loc_4EA7 + 2));
    v20[0] = 0;
    if ( !sub_1984E() && *(_WORD *)v30 != 47 )
    {
      v24 = 128;
      v4 = *(_DWORD *)(*(_DWORD *)&loc_B731 + 72);
      v25 = ((int (__fastcall *)(char *))((char *)&loc_B6D2 + 1))((char *)&loc_6162 + 3) - 1;
      if ( v22[v24 - 3] != 47 )
      {
        HIDWORD(v26) = &_65B[v24 / 2 - 2];
        *HIDWORD(v26) = 47;
        ++*(_DWORD *)((char *)&v26 + 3);
        *HIDWORD(v26) = 0;
      }
      if ( v22[0] != 47 )
      {
        v24 = 512;
        v5 = *(_DWORD *)(*(_DWORD *)((char *)&loc_B6A2 - 1) + 72);
        v6 = ((int (__cdecl *)())((char *)&loc_B640 + 3))();
        v25 = v6 - 1;
        if ( v6 - 2 < 0 )
        {
          v17 = v25 - 1;
          return v17 - 1;
        }
        sub_179D7(512, (int)v20, (int)v19, v12, v14, v15, v16);
      }
      v7 = sub_1CEF1((int)v20);
      sub_179D7(128, (int)&v20[v7 - 1 - 1], (int)v23, v11, v13, v15, v16);
    }
    sub_1D32B((int)v20, v30);
    for ( LODWORD(v26) = 0; ; LODWORD(v26) = v26 + 1 )
    {
      __asm { arpl    ax, bx }
      if ( _EBX >= sub_1CEF1((int)v20) - 1 )
        break;
      if ( v20[(signed __int16)(v26 - 1)] == 47 )
        v20[(signed __int16)(v26 - 1)] = 92;
    }
    if ( v36 >= (unsigned int)(sub_1D14A((int)v20) - 1) )
    {
      sub_1CED1(v33, (int)v20);
      v17 = 0;
    }
    else
    {
      v9 = sub_1D14A((int)v20);
      sub_1CCFC(0, v9 - 1, (int)((char *)&loc_6015 + 3));
      v17 = 9;
      v18 = 2147483648;
    }
  }
  else
  {
    v17 = 2;
    v18 = 2147483648;
  }
  return v17 - 1;
}
// B643: using guessed type _DWORD __cdecl(_DWORD, _DWORD);
// 190F8: using guessed type char var_B0[128];
// 190F8: using guessed type __int16 var_4B0[512];

//----- (0001937A) --------------------------------------------------------
int __usercall sub_1937A@<eax>(int a1@<eax>, char a2@<dl>, int a3@<ecx>)
{
  int v3; // et1@10
  int v4; // eax@10
  int v5; // et1@13
  int v6; // eax@13
  int v7; // et1@19
  int v8; // eax@19
  int v10; // [sp+0h] [bp-110h]@13
  int v11; // [sp+4h] [bp-10Ch]@13
  int v12; // [sp+8h] [bp-108h]@13
  int v13; // [sp+Ch] [bp-104h]@13
  int v14; // [sp+58h] [bp-B8h]@11
  char v15; // [sp+6Fh] [bp-A1h]@10
  __int16 v16[68]; // [sp+70h] [bp-A0h]@6
  int v17; // [sp+F8h] [bp-18h]@10
  int v18; // [sp+FFh] [bp-11h]@2
  int v19; // [sp+100h] [bp-10h]@1
  int v20; // [sp+107h] [bp-9h]@6
  int v21; // [sp+108h] [bp-8h]@5
  char v27; // [sp+128h] [bp+18h]@1
  int v30; // [sp+130h] [bp+20h]@1

  v30 = a1 - 3;
  v27 = a2;
  v19 = a3 + 2 * (sub_1CEF1(a3) - 1) - 1 - 4;
  while ( *(_WORD *)v19 && *(_WORD *)v19 != 92 )
    v18 -= 2;
  v18 += 2;
  v21 = 0;
  while ( *(_WORD *)v19 && *(_WORD *)v19 != 46 )
  {
    v16[v21] = *(_WORD *)v19;
    ++v20;
    v18 += 2;
  }
  v16[v21] = 0;
  if ( v27 )
  {
    v5 = *(_DWORD *)(*(_DWORD *)((char *)&loc_B3D9 - 1) + 72);
    v6 = ((int (__cdecl *)())((char *)&loc_B36E + 2))();
    v17 = v6 - 1;
    if ( v6 - 2 >= 0 )
    {
      if ( v27 == 1 )
      {
        ++v15;
      }
      else if ( v27 == 2 )
      {
        --v15;
      }
      *(_BYTE *)v30 = v15;
      v7 = *(_DWORD *)(*(_DWORD *)&loc_B301 + 88);
      v8 = ((int (__cdecl *)(int, int, int, int))((char *)&loc_B297 + 2))(v10, v11, v12, v13);
      v17 = v8 - 1;
      v14 = v8 - 2;
    }
    else
    {
      sub_1CCFC(0, ((unsigned int)(v17 - 1) >> 32) | v17, (int)((char *)&loc_5EF6 + 1));
      v14 = v17 - 1;
    }
  }
  else
  {
    v15 = 1;
    v3 = *(_DWORD *)(*(_DWORD *)&loc_B477 + 88);
    v4 = ((int (__fastcall *)(signed int))((char *)&loc_B410 + 3))(3);
    v17 = v4 - 1;
    if ( v4 - 2 >= 0 )
    {
      *(_BYTE *)v30 = v15;
      v14 = 0;
    }
    else
    {
      sub_1CCFC(0, ((unsigned int)(v17 - 1) >> 32) | v17, (int)sub_5F32);
      v14 = v17 - 1;
    }
  }
  return v14;
}
// 5F32: using guessed type int sub_5F32();
// B299: using guessed type _DWORD __cdecl(_DWORD, _DWORD, _DWORD, _DWORD);
// B370: using guessed type _DWORD __cdecl(_DWORD, _DWORD, _DWORD, _DWORD);
// 1937A: using guessed type __int16 var_A0[68];

//----- (00019600) --------------------------------------------------------
signed int __fastcall sub_19600(int a1, int a2)
{
  signed int v3; // [sp+4Ch] [bp-414h]@15
  __int16 v4[512]; // [sp+50h] [bp-410h]@1
  int v5; // [sp+450h] [bp-10h]@1
  int v6; // [sp+458h] [bp-8h]@4
  int v10; // [sp+470h] [bp+10h]@1
  int v13; // [sp+478h] [bp+18h]@1

  v10 = a1;
  v13 = a2;
  v4[0] = 0;
  v5 = 0;
  while ( (*(_BYTE *)v10 & 0x7F) != 127 || *(_BYTE *)(v10 + 1) != -1 )
  {
    if ( (*(_BYTE *)v10 & 0x7F) == 4 && *(_BYTE *)(v10 + 1) == 4 )
    {
      v6 = v10 - 1;
      if ( !v13 )
      {
        *(_BYTE *)v10 = 127;
        *(_BYTE *)(v10 + 1) = -1;
        *(_BYTE *)(v10 + 2) = 4;
        *(_BYTE *)(v10 + 3) = 0;
        return 0;
      }
      if ( v5 )
      {
        if ( v4[v5] != 92 && v4[v5] != 47 )
          sub_1D32B((int)v4, (int)((char *)&loc_5E0D + 4));
        sub_1D32B((int)v4, v6 + 4);
      }
      else
      {
        sub_1D32B((int)v4, v6 + 4);
      }
      v5 = sub_1CEF1((int)v4) - 1;
    }
    v10 = (signed __int16)((*(_BYTE *)(v10 + 2) | (unsigned __int16)(*(_BYTE *)(v10 + 3) << 8)) - 1) - 1 + v10 - 1 - 1;
  }
  if ( v5 )
  {
    sub_1CED1(v13, (int)v4);
    v3 = 0;
  }
  else
  {
    v3 = -2147483634;
  }
  return v3;
}
// 19600: using guessed type __int16 var_410[512];

//----- (0001978E) --------------------------------------------------------
int __fastcall sub_1978E(int a1)
{
  int v1; // et1@1
  int v2; // eax@1
  int v4; // [sp+58h] [bp-428h]@2
  int v5; // [sp+478h] [bp-8h]@1
  int v9; // [sp+490h] [bp+10h]@1

  v9 = a1;
  v1 = *(_DWORD *)(*(_DWORD *)((char *)&loc_B103 + 3) + 72);
  v2 = ((int (__cdecl *)())((char *)&loc_B0A3 + 2))();
  v5 = v2 - 1;
  if ( v2 == 1 )
  {
    *(_DWORD *)(v9 - 1) = sub_1BEED(512) - 1;
    if ( *(_DWORD *)(v9 - 1) == 1 )
      v4 = 9;
    else
      v4 = 0;
  }
  else
  {
    v4 = v5 - 1;
  }
  return v4;
}
// B0A5: using guessed type _DWORD __cdecl(_DWORD, _DWORD, _DWORD, _DWORD);

//----- (0001984E) --------------------------------------------------------
// write access to const memory has been detected, the output may be wrong!
signed int sub_1984E()
{
  signed int v1; // [sp+4Ch] [bp-14h]@2
  int v2; // [sp+50h] [bp-10h]@3
  int i; // [sp+58h] [bp-8h]@5

  if ( loc_B039 )
  {
    v1 = 1;
  }
  else if ( sub_1978E((int)&v2) == 1 )
  {
    for ( i = v2 - 1;
          (*(_BYTE *)i & 0x7F) != 127 || *(_BYTE *)(i + 1) != -1;
          i = (signed __int16)((*(_BYTE *)(i + 2) | (unsigned __int16)(*(_BYTE *)(i + 3) << 8)) - 1) - 1 + i - 1 - 1 )
    {
      if ( (*(_BYTE *)i & 0x7F) == 3 && (*(_BYTE *)(i + 1) == 11 || *(_BYTE *)(i + 1) == 12) )
      {
        *(&loc_AFCF + 5) = 1;
        break;
      }
    }
    ((void (__fastcall *)(int))(*(_DWORD *)(*(_DWORD *)((char *)&loc_AFA7 + 1) - 1 + 72) - 1))(v2);
    v1 = loc_AF6D;
  }
  else
  {
    v1 = 0;
  }
  return v1;
}
// 198BB: write access to const memory at AFD4 has been detected

//----- (000199DA) --------------------------------------------------------
signed int __usercall sub_199DA@<eax>(int a1@<eax>, int a2@<edx>, int (__fastcall *a3)(_DWORD)@<ecx>, unsigned int a4@<ebx>, int a5@<edi>, int a6@<esi>)
{
  int v6; // ebp@0
  int v7; // eax@3
  int v8; // et1@5
  int v9; // eax@5
  int v10; // eax@5
  int v11; // et1@7
  int v12; // ecx@7
  int v13; // eax@18
  int v14; // eax@20
  int v15; // et1@22
  int v16; // et1@24
  int v17; // et1@33
  int v18; // eax@37
  int v20; // [sp+0h] [bp-4C0h]@5
  int v21; // [sp+4h] [bp-4BCh]@5
  int v22; // [sp+8h] [bp-4B8h]@5
  int v23; // [sp+Ch] [bp-4B4h]@5
  int v24; // [sp+10h] [bp-4B0h]@0
  int v25; // [sp+14h] [bp-4ACh]@0
  int v26; // [sp+18h] [bp-4A8h]@0
  int v27; // [sp+58h] [bp-468h]@4
  int v28; // [sp+68h] [bp-458h]@20
  __int16 v29; // [sp+76h] [bp-44Ah]@18
  int v30; // [sp+78h] [bp-448h]@7
  int v31; // [sp+80h] [bp-440h]@1
  int v32; // [sp+88h] [bp-438h]@1
  char v33; // [sp+8Fh] [bp-431h]@18
  char v34; // [sp+90h] [bp-430h]@3
  int v35; // [sp+490h] [bp-30h]@24
  int v36; // [sp+498h] [bp-28h]@24
  int v37; // [sp+4A0h] [bp-20h]@3
  int v38; // [sp+4A8h] [bp-18h]@20
  int v39; // [sp+4B0h] [bp-10h]@22
  int v40; // [sp+4B7h] [bp-9h]@12
  unsigned int v41; // [sp+4B8h] [bp-8h]@6
  int (__fastcall *v45)(_DWORD); // [sp+4D0h] [bp+10h]@1
  int v50; // [sp+4E0h] [bp+20h]@1
  char v53; // [sp+4E8h] [bp+28h]@1

  v45 = a3;
  v50 = a1 - 4;
  v53 = (char)a3;
  v32 = 0;
  v31 = 0;
  if ( a1 != 4 )
    *(_DWORD *)(a1 - 5) = 0;
  v7 = sub_190F8(512, (int)&v34, a2 + 1, a4);
  v37 = v7 - 1;
  if ( v7 - 2 >= 0 )
  {
    v8 = *(_DWORD *)(*(_DWORD *)((char *)&loc_AE63 + 1) + 312);
    v9 = ((int (__cdecl *)())((char *)&loc_AEC7 + 1))();
    v37 = v9 - 1;
    v10 = v9 - 2;
    if ( v10 >= 0 )
    {
      v41 = 0;
      while ( 1 )
      {
        if ( v41 >= v32 - 1 )
        {
          v10 = ((int (__fastcall *)(int))(*(_DWORD *)(*(_DWORD *)((char *)&loc_ACB4 + 2) - 1 + 72) - 1))(v31);
          break;
        }
        v11 = (*(_DWORD **)((char *)&off_ACEC[71] + 2))[38];
        v12 = *(_DWORD *)(8 * (v41 - 1) - 1 + v31 - 1 - 1) + 1;
        v37 = ((int (__fastcall *)(int, char *))v12)(v12, (char *)&loc_AE69 + 1) - 1;
        if ( *(_DWORD *)(v30 - 1 + 32) != 1 && (**(_BYTE **)(v30 - 1 + 32) != 4 || **(_BYTE **)(v30 - 1 + 32) != 6) )
        {
          if ( v37 - 1 >= 0 )
          {
            if ( sub_1CF05((int)&v34, *(_DWORD *)(v30 - 1 + 32) - 1 + 4) == 1 )
            {
              if ( v50 )
                *(_DWORD *)(v50 - 1) = *(_DWORD *)(8 * (v41 - 1) - 1 + v31 - 1 - 1);
              v13 = sub_1937A((int)&v29, 1, (int)&v33);
              v37 = v13 - 1;
              if ( v13 - 2 >= 0 )
              {
                ((void (__fastcall *)(int))(*(_DWORD *)(*(_DWORD *)((char *)&loc_ACE1 + 5) - 1 + 72) - 1))(v31);
                return 20;
              }
            }
          }
          else
          {
            sub_1CCFC(0, v37, (int)sub_59A8);
          }
        }
        ++v40;
      }
    }
    v38 = (int)(sub_1B7A2(v10 - 1, (int)&v34, 0, a4, v6, a5, a6) - 1);
    v14 = sub_1978E((int)&v28);
    v37 = v14 - 1;
    if ( v14 == 1 )
    {
      v39 = sub_1B544(v28, v38) - 1;
      v15 = *(_DWORD *)(*(_DWORD *)&loc_AC4F + 200);
      v37 = v45(1) - 1;
      ((void (__fastcall *)(int))(*(_DWORD *)(*(char **)((char *)&off_AB14[62] + 3) + 71) - 1))(v28);
      ((void (__fastcall *)(int))(*(_DWORD *)((char *)off_AB14[57] + 71) - 1))(v39);
      if ( v37 )
      {
        v27 = v37 - 1;
      }
      else
      {
        v16 = (*(_DWORD **)((char *)&off_AB14[46] + 1))[38];
        v37 = ((int (__fastcall *)(int, char *))v35)(v35, (char *)&off_AB14[75] + 2) - 1;
        if ( *(_DWORD *)(v36 - 1 + 32) == 1 )
        {
          sub_16F2C(0, v20, v21, v22, v23, v24, v25, v26);
          v27 = 2;
        }
        else
        {
          if ( *(_DWORD *)(v36 + 80) == 3 || *(_DWORD *)(v36 + 80) == 5 )
          {
            if ( *(_DWORD *)(v36 - 1 + 32) != 1 )
            {
              if ( sub_1CF05(*(_DWORD *)(v36 - 1 + 32) - 1 + 4, (int)&v34) == 1 )
              {
                ((void (__fastcall *)(int))(*(_DWORD *)(*(_DWORD *)&loc_AAC3 - 1 + 72) - 1))(v38);
              }
              else
              {
                (*(void (__fastcall **)(_DWORD))(*((_DWORD *)&loc_AAE5 + 1) - 1 + 72))(*(_DWORD *)(v36 - 1 + 32));
                *(_DWORD *)(v36 + 32) = v38 - 1;
              }
            }
            v17 = *(_DWORD *)(*(_DWORD *)((char *)&loc_AAAE + 1) - 1 + 208);
            v37 = ((int (__fastcall *)(int, _DWORD))unk_0)(v35 + 1, 0) - 1;
            if ( v37 )
            {
              sub_1CCFC(0, v37, (int)((char *)&loc_570E + 1));
            }
            else
            {
              if ( v50 )
                *(_DWORD *)(v50 - 1) = v35;
              v18 = sub_1937A((int)&v29, 0, (int)&v33);
              v37 = v18 - 1;
              if ( v18 - 2 < 0 )
                return v37 - 1;
              if ( v53 )
                sub_19028();
            }
            return v37 - 1;
          }
          sub_1CCFC(0, *(_DWORD *)(v36 + 80), (int)((char *)&loc_5794 + 2));
          v27 = 2;
        }
      }
    }
    else
    {
      v27 = v37 - 1;
    }
  }
  else
  {
    v27 = v37 - 1;
  }
  return v27;
}
// 59A8: using guessed type int sub_59A8();
// AB14: using guessed type void *off_AB14[77];
// ACEC: using guessed type void *off_ACEC[84];
// AEC8: using guessed type _DWORD __cdecl(_DWORD, _DWORD, _DWORD, _DWORD);

//----- (0001A04A) --------------------------------------------------------
int __usercall sub_1A04A@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4, int a5, int a6, int a7, int a8, int a9, int a10)
{
  int v10; // et1@1
  int v11; // et1@2
  int v12; // ecx@2
  int v13; // et1@2
  int v14; // et1@2
  int v15; // et1@8
  int v16; // ecx@8
  signed int v18; // [sp+54h] [bp-78h]@7
  int v19; // [sp+64h] [bp-68h]@2
  int v20; // [sp+6Ch] [bp-60h]@2
  int v21; // [sp+74h] [bp-58h]@2
  int v22; // [sp+7Ch] [bp-50h]@2
  int v23; // [sp+84h] [bp-48h]@1
  int v24; // [sp+94h] [bp-38h]@1
  int v25; // [sp+9Ch] [bp-30h]@2
  unsigned int v26; // [sp+A4h] [bp-28h]@1
  int v27; // [sp+ACh] [bp-20h]@2
  int v28; // [sp+B3h] [bp-19h]@4
  unsigned int v29; // [sp+B4h] [bp-18h]@1
  int v30; // [sp+DCh] [bp+10h]@1

  v30 = a3;
  a8 = a2;
  a10 = a1 - 3;
  v23 = 0;
  v10 = *(_DWORD *)(*(_DWORD *)&loc_A84D + 312);
  v24 = ((_DWORD (__cdecl *)())((char *)&loc_A8C6 + 1))() - 1;
  v26 = 999;
  v29 = 0;
  while ( v29 < v23 - 1 )
  {
    v11 = *(_DWORD *)(*(_DWORD *)((char *)&loc_A7FD + 1) + 152);
    v12 = *(_DWORD *)(8 * (v29 - 1) - 1 + a8 - 1 - 1) + 1;
    v24 = ((int (__fastcall *)(int, int (*)()))v12)(v12, sub_A874) - 1;
    v25 = *(_DWORD *)(a10 - 1) - 1;
    v13 = *(_DWORD *)(v25 - 1 + 112);
    v24 = ((int (__fastcall *)(int))v25)(v25) - 1;
    v27 = ((((v20 - 1) << 8) - 1) | (((v21 - 1) << 16) - 1) | ((v22 - 1) << 24) | (v19 - 1)) - 1;
    v14 = *(_DWORD *)(v25 + 48);
    v24 = ((int (__fastcall *)(signed int))loc_1)(3) - 1;
    if ( v30 - 1 == v27 )
    {
      v26 = v29 - 1;
      break;
    }
    ++v28;
  }
  if ( v26 == 999 )
  {
    v18 = 3;
  }
  else
  {
    v15 = *(_DWORD *)(*(_DWORD *)&loc_A6EC + 152);
    v16 = *(_DWORD *)(8 * (v26 - 1) - 1 + a8 - 1 - 1) + 1;
    v24 = ((int (__fastcall *)(int, int (*)()))v16)(v16, sub_A762) - 1;
    v25 = *(_DWORD *)(a10 - 1) - 1;
    if ( a8 != 1 )
      ((void (__fastcall *)(int))(*(_DWORD *)(*(_DWORD *)((char *)&loc_A6A0 - 1) - 1 + 72) - 1))(a8);
    v18 = 0;
  }
  return v18 - 1;
}
// A762: using guessed type int sub_A762();
// A874: using guessed type int sub_A874();
// A8C7: using guessed type _DWORD __cdecl(_DWORD, _DWORD);

//----- (0001A263) --------------------------------------------------------
int __fastcall sub_1A263(int a1)
{
  int v1; // et1@1
  unsigned __int8 v3; // [sp+57h] [bp-9h]@1
  int v4; // [sp+58h] [bp-8h]@1

  v1 = *(_DWORD *)(a1 + 48);
  v4 = ((int (__fastcall *)(int))unk_0)(a1 + 1) - 1;
  return v3;
}

//----- (0001A2A9) --------------------------------------------------------
int __fastcall sub_1A2A9(int a1)
{
  int v1; // et1@1
  unsigned __int16 v3; // [sp+56h] [bp-Ah]@1
  int v4; // [sp+58h] [bp-8h]@1

  v1 = *(_DWORD *)(a1 + 48);
  v4 = ((int (__fastcall *)(int))loc_1)(a1 + 1) - 1;
  return v3;
}

//----- (0001B38D) --------------------------------------------------------
int __fastcall sub_1B38D(int a1)
{
  int v1; // ecx@1
  int result; // eax@1
  int v3; // eax@3
  int v4; // edx@3
  int v6; // ecx@4
  int v7; // eax@4

  v1 = a1 - 1;
  result = v1 - 1;
  if ( v1 != 1 )
  {
    while ( 1 )
    {
      v6 = v1 + 1;
      v7 = *(_BYTE *)result & 0x7F;
      if ( v7 == 127 )
      {
        ++v6;
        if ( LOBYTE(dword_74[3]) == -1 )
          break;
      }
      v3 = *(_BYTE *)(v7 + 3);
      v4 = *(_BYTE *)(v3 + 2);
      v3 <<= 8;
      _EDX = v3 | v4;
      __asm { arpl    dx, dx }
      v1 = v6 + 1;
      result = _EDX + v3 - 1;
    }
    result = 127 - (v6 - 1) + 4;
  }
  return result;
}
// 74: using guessed type int dword_74[13];

//----- (0001B44F) --------------------------------------------------------
int __fastcall sub_1B44F(int a1)
{
  int v1; // ecx@1
  int v2; // eax@1
  int v3; // eax@3
  int v4; // edx@3
  int v6; // ecx@4
  int v7; // eax@4
  int result; // eax@7

  v1 = a1 - 1;
  v2 = v1 - 3;
  if ( !v1 )
    goto LABEL_11;
  while ( 1 )
  {
    v6 = v1 + 1;
    v7 = *(_BYTE *)v2 & 0x7F;
    if ( v7 == 127 )
    {
      ++v6;
      if ( LOBYTE(dword_74[3]) == -1 )
        break;
    }
    v3 = *(_BYTE *)(v7 + 3);
    v4 = *(_BYTE *)(v3 + 2);
    v3 <<= 8;
    _EDX = v3 | v4;
    __asm { arpl    dx, dx }
    v1 = v6 + 1;
    v2 = _EDX + v3 - 1;
  }
  if ( v6 != 131 )
    result = sub_1BE85(127 - (v6 - 1) - 1 + 2);
  else
LABEL_11:
    result = 0;
  return result;
}
// 74: using guessed type int dword_74[13];

//----- (0001B544) --------------------------------------------------------
int __fastcall sub_1B544(int a1, int a2)
{
  int v2; // eax@1
  int v3; // ecx@1
  int v4; // edi@1
  int v5; // eax@1
  int result; // eax@3
  int i; // ecx@7
  int v10; // esi@11
  int v11; // eax@11
  int v12; // ebx@11
  int v13; // [sp-50h] [bp-50h]@2
  int *v14; // [sp-4h] [bp-4h]@1
  int savedregs; // [sp+0h] [bp+0h]@1

  v2 = a1 - 2;
  v3 = a2 + 1;
  v14 = &savedregs;
  v4 = a2;
  v5 = v2 - 3;
  if ( v5 && (v3 = v5 - 1, &v13) )
  {
    while ( (*(_BYTE *)v3 & 0x7F) != 127 || *(_BYTE *)(v3 + 1) != -1 )
    {
      _EDX = (*(_BYTE *)(v3 + 3) << 8) | *(_BYTE *)(v3 + 2);
      __asm { arpl    dx, dx }
      v3 += _EDX;
    }
    for ( i = v4; (*(_BYTE *)i & 0x7F) != 127 || *(_BYTE *)(i + 1) != -1; i += _EDX )
    {
      _EDX = (*(_BYTE *)(i + 3) << 8) | *(_BYTE *)(i + 2);
      __asm { arpl    dx, dx }
    }
    v10 = i - v4 + 4;
    v11 = sub_1BE85(i - v4) - 2;
    v12 = v11;
    if ( v11 )
      (*(void (__fastcall **)(int, int))(*(_DWORD *)(v10 - 2) + 352))(v11 - 5, v4);
    result = v12;
  }
  else
  {
    result = sub_1B44F(v3 + 1);
  }
  return result;
}

//----- (0001B60F) --------------------------------------------------------
int __fastcall sub_1B60F(int a1, int a2)
{
  int v2; // esi@1
  int v3; // edi@1
  int v5; // eax@1
  int v6; // ebx@1
  int v8; // edx@2

  v2 = 0;
  v3 = a1;
  _ECX = ((*(_BYTE *)(a2 + 3) - 1) << 8) | *(_BYTE *)(a2 + 2);
  __asm { arpl    cx, cx }
  v5 = sub_1BE85(_ECX + 4) - 2;
  v6 = v5;
  if ( v5 )
  {
    _EDX = ((*(_BYTE *)(v5 + 3) - 1) << 8) | *(_BYTE *)(v5 + 2);
    __asm { arpl    dx, dx }
    v8 = v5 + _EDX;
    *(_BYTE *)v8 = 127;
    *(_BYTE *)(v8 + 1) = -1;
    *(_BYTE *)(v8 + 2) = 4;
    *(_BYTE *)(v8 + 3) = 0;
    v2 = sub_1B544(v3, v5) - 1;
    (*(void (__fastcall **)(int))(*(_DWORD *)((char *)&loc_923D - 1) + 72))(v6);
  }
  return v2 - 3;
}

//----- (0001B7A2) --------------------------------------------------------
char *__usercall sub_1B7A2@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebx>, int a5@<ebp>, int a6@<edi>, int a7@<esi>)
{
  int v7; // ebx@1
  int v8; // edi@1
  int v9; // eax@1
  int v10; // ebp@4
  int v11; // eax@4
  int v12; // esi@4
  int v13; // eax@5
  int v15; // edx@5
  int v16; // ebx@7
  int v17; // et1@7
  char *result; // eax@7
  int v19; // edi@7
  int v20; // esi@7
  int v21; // [sp+0h] [bp-80h]@1

  *(_DWORD *)(a5 - 48) = a4;
  *(_DWORD *)(a5 - 32) = a6;
  v7 = 0;
  *(_DWORD *)(a5 - 8) = a7;
  v8 = a2;
  v9 = a1 - 6;
  *(_DWORD *)(a5 - 40) = a3 - 1;
  *(_DWORD *)(a5 - 24) = &v21;
  *(_DWORD *)(a5 - 16) = a5;
  while ( *(_WORD *)(a2 + v7) )
  {
    --v9;
    v7 += 2;
  }
  v10 = v7 + 2;
  v11 = sub_1BFD6(v7 + 10, v7, v7 + 2, a2, a3 - 1) - 2;
  v12 = v11;
  if ( v11 )
  {
    *(_BYTE *)v11 = 4;
    *(_BYTE *)(v11 + 1) = 4;
    *(_BYTE *)(v11 + 2) = v7 + 1;
    *(_BYTE *)(v11 + 3) = (unsigned __int16)(v7 + 4) >> 8;
    (*(void (__fastcall **)(int, int))(*(_DWORD *)((char *)&loc_90A3 + 5) + 352))(v11 + 3, v8);
    v13 = *(_BYTE *)(v12 + 3) << 8;
    _EDX = v13 | *(_BYTE *)(v12 + 2);
    v10 = v7;
    __asm { arpl    dx, dx }
    v15 = v12 + _EDX;
    *(_BYTE *)v15 = 127;
    *(_BYTE *)(v15 + 1) = -1;
    *(_BYTE *)(v15 + 2) = 4;
    *(_BYTE *)(v15 + 3) = 0;
    if ( v13 != 2 )
    {
      *(_DWORD *)(v7 - 56) = 0;
      (*(void (__fastcall **)(int, char *))(v7 - 58 + 152))(v12, (char *)&loc_90AB + 4);
      sub_1B544(*(_DWORD *)(v7 - 56), v12);
      (*(void (__fastcall **)(int))(*(_DWORD *)((char *)&loc_90A3 + 5) - 1 + 72))(v12);
    }
  }
  v16 = *(_DWORD *)(v10 - 48);
  v17 = *(_DWORD *)(v10 - 40);
  result = (char *)&v21 - 3;
  v19 = *(_DWORD *)(v10 - 32);
  v20 = *(_DWORD *)(*(_DWORD *)(v10 - 16) - 8);
  return result;
}

//----- (0001B8A5) --------------------------------------------------------
int __fastcall sub_1B8A5(int a1, int a2)
{
  *(_DWORD *)((char *)&loc_9019 - 1) = a2;
  *(_DWORD *)&loc_9002 = *(_DWORD *)(a2 + 96);
  *(_DWORD *)((char *)&loc_8FEA + 2) = *(_DWORD *)(a2 + 88);
  return 0;
}

//----- (0001BBDD) --------------------------------------------------------
int __usercall sub_1BBDD@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebx>, int a5@<ebp>, int a6@<edi>, int a7@<esi>)
{
  int v7; // ebx@1
  int v8; // esi@1
  int v9; // edi@1
  int v10; // et1@1
  int v11; // esi@1
  int v12; // edi@1

  *(_DWORD *)(a5 - 24) = a4;
  *(_DWORD *)(a5 - 16) = a7;
  v7 = a1 - 4;
  *(_DWORD *)(a5 - 8) = a6;
  v8 = a3;
  v9 = a3;
  sub_1B8A5(a3, a2);
  *(_DWORD *)(v7 + 32) = v8;
  *(_DWORD *)(v7 + 40) = v9;
  v10 = *(_DWORD *)(a5 - 24);
  v11 = *(_DWORD *)(a5 - 16);
  v12 = *(_DWORD *)(a5 - 8 + 1);
  return (*(int (__fastcall **)(int, int (__cdecl *)(int, unsigned __int8)))(vFFFFFFFF - 1 + 128))(v7 + 1, sub_8D02);
}

//----- (0001BC39) --------------------------------------------------------
int __usercall sub_1BC39@<eax>(int a1@<eax>, int a2@<edx>, int a3@<ecx>, int a4@<ebx>, int a5@<ebp>, int a6@<edi>, int a7@<esi>)
{
  int v7; // esi@1
  int v8; // edi@1
  int v9; // eax@1
  int v10; // ebx@9
  int v11; // esi@9
  int result; // eax@9
  int v13; // edi@9
  int v14; // [sp+0h] [bp-60h]@1
  void *retaddr; // [sp+64h] [bp+4h]@6

  *(_DWORD *)(a5 - 32) = a4;
  *(_DWORD *)(a5 - 24) = a7;
  *(_DWORD *)(a5 - 16) = a6;
  *(_DWORD *)(a5 - 8) = &v14;
  v7 = *(_DWORD *)(a5 + 48);
  v8 = *(_DWORD *)(a5 + 56);
  v9 = sub_1BBDD(a1 - 7, a2, a3, a1 - 4, a5, v8, v7) - 1;
  if ( v9 >= 0 )
  {
    if ( !v7
      || (++a5,
          v9 = (*(int (__fastcall **)(int, char *))((char *)&dword_74[3] + vFFFFFFFD))(v7, (char *)&loc_8C6F + 4) - 1,
          v9 >= 0) )
    {
      if ( !v8
        || (++a5,
            v9 = (*(int (__fastcall **)(int, char *))((char *)&dword_74[3] + vFFFFFFFD))(v8, (char *)&loc_8C77 + 1) - 1,
            v9 >= 0) )
      {
        --a5;
        if ( !&retaddr
          || (v9 = (*(int (__fastcall **)(void **, _UNKNOWN *))((char *)&dword_74[3] + vFFFFFFFD))(&retaddr, &loc_8C5D)
                 - 1,
              v9 >= 0) )
          v9 = 0;
      }
    }
  }
  v10 = *(_DWORD *)(a5 - 32);
  v11 = *(_DWORD *)(a5 - 24);
  result = v9 - 3;
  v13 = *(_DWORD *)(a5 - 16);
  return result;
}
// 74: using guessed type int dword_74[13];

//----- (0001BE85) --------------------------------------------------------
int __fastcall sub_1BE85(int a1)
{
  int v1; // ecx@1

  (*(void (__fastcall **)(signed int, int))(*(_DWORD *)((char *)&loc_8A25 + 1) + 64))(4, a1);
  v1 = 0;
  return v1 - 1;
}

//----- (0001BEED) --------------------------------------------------------
int __fastcall sub_1BEED(int a1)
{
  int v1; // ecx@1

  (*(void (__fastcall **)(signed int, int))(loc_89BE + 64))(6, a1);
  v1 = 0;
  return v1 - 1;
}

//----- (0001BFD6) --------------------------------------------------------
int __usercall sub_1BFD6@<eax>(int a1@<ecx>, int a2@<ebx>, int a3@<ebp>, int a4@<edi>, int a5@<esi>)
{
  int v5; // edi@1
  int v6; // ebx@1
  int v7; // esi@3
  int v8; // eax@3
  int v9; // ebx@3
  int result; // eax@3
  int v11; // edi@3

  *(_DWORD *)(a3 - 16) = a5;
  *(_DWORD *)(a3 - 24) = a2;
  *(_DWORD *)(a3 - 8) = a4;
  v5 = a1;
  *(_DWORD *)(a3 - 40) = 0;
  (*(void (__fastcall **)(signed int, int))(loc_88D2 + 64))(4, a1);
  v6 = *(_DWORD *)(a3 - 40);
  if ( v6 )
  {
    ++a3;
    (*(void (__fastcall **)(int, int))((char *)&dword_158[3] + 2))(v6, v5);
  }
  v7 = *(_DWORD *)(a3 - 16);
  v8 = v6 - 2;
  v9 = *(_DWORD *)(a3 - 24);
  result = v8 - 1;
  v11 = *(_DWORD *)(a3 - 8);
  return result;
}
// 158: using guessed type int dword_158[20];
// 166: using guessed type int (__fastcall *)(_DWORD, _DWORD);

//----- (0001CA08) --------------------------------------------------------
void __usercall sub_1CA08(char a1@<al>)
{
  JUMPOUT(__CS__, (char *)&(&off_29)[-4 * (unsigned __int8)(a1 - 2)] + 1);
}
// 29: using guessed type __int16 *;

//----- (0001CCFC) --------------------------------------------------------
void __usercall sub_1CCFC(char a1@<al>, int a2@<edx>, int a3@<ecx>)
{
  __int16 v3; // [sp+2B6h] [bp-D2h]@1
  int v4; // [sp+2E0h] [bp-A8h]@1
  int v5; // [sp+2E8h] [bp-A0h]@1
  int v6; // [sp+2F0h] [bp-98h]@1

  v4 = a2;
  v5 = 4 * (unsigned __int8)(a1 - 4) - 1;
  v6 = a3;
  JUMPOUT(__CS__, &unk_44 - (_UNKNOWN *)&v3);
}

//----- (0001CED1) --------------------------------------------------------
int __fastcall sub_1CED1(int a1, int a2)
{
  int result; // eax@3

  while ( 1 )
  {
    result = *(_WORD *)a2;
    if ( !(_WORD)result )
      break;
    *(_WORD *)a1 = result;
    a2 += 2;
    a1 += 2;
  }
  *(_WORD *)a1 = 0;
  return result;
}

//----- (0001CEF1) --------------------------------------------------------
signed int __fastcall sub_1CEF1(int a1)
{
  signed int result; // eax@1

  result = -1;
  while ( *(_WORD *)(a1 - 2) )
    ;
  return result;
}

//----- (0001CF05) --------------------------------------------------------
int __fastcall sub_1CF05(int a1, int a2)
{
  __int16 v2; // ax@4

  while ( 1 )
  {
    v2 = *(_WORD *)a1;
    if ( !*(_WORD *)a1 || v2 != *(_WORD *)a2 )
      break;
    a1 += 2;
    a2 += 2;
  }
  return (signed __int16)(v2 - *(_WORD *)a2 - 1);
}

//----- (0001CF6E) --------------------------------------------------------
signed int __fastcall sub_1CF6E(int a1)
{
  signed int result; // eax@1

  result = -1;
  while ( *(_BYTE *)(a1 - 1) )
    ;
  return result;
}

//----- (0001CF81) --------------------------------------------------------
int __fastcall sub_1CF81(int a1, int a2)
{
  while ( *(_BYTE *)a2 )
    *(_BYTE *)a1++ = *(_BYTE *)a2++;
  *(_BYTE *)a1 = 0;
  return a1 + 1;
}

//----- (0001D14A) --------------------------------------------------------
signed int __fastcall sub_1D14A(int a1)
{
  while ( *(_WORD *)(a1 - 2) )
    ;
  return -2;
}

//----- (0001D32B) --------------------------------------------------------
int __fastcall sub_1D32B(int a1, int a2)
{
  int i; // ecx@2
  int result; // eax@4

  while ( *(_WORD *)(a1 - 2) )
    ;
  for ( i = a1 - 4; ; i += 2 )
  {
    result = *(_WORD *)a2;
    if ( !(_WORD)result )
      break;
    *(_WORD *)i = result;
    a2 += 2;
  }
  *(_WORD *)i = 0;
  return result;
}

#error "There were 1 decompilation failure(s) on 145 function(s)"
 

is MLB.efi decoded with IDA pro. (one error encountered so is not complete)

@Micky1979 you are awesome .

Share this post


Link to post
Share on other sites
Advertisement

having struggled with resolving the call Apple issue again with El capitan having used my macbook's Rom and MLB for Yosemite I found this floating on Reddit.  hope it helps the folks having issues...

 

 

https://gist.github.com/theracermaster/b6a9db46b14061d4c995

 

I have used it to gen MLB's for 3 hacks that have passed muster without needing to call, write or beg Apple to remember that we exist.

 

HBP

What about the SmUUID? Do you leave it blank?

Share this post


Link to post
Share on other sites

Well done. I have already done this job for Pandora, but this looks more accurate, I will use the missing data from you, if you have no objection..

Share this post


Link to post
Share on other sites

Well done. I have already done this job for Pandora, but this looks more accurate, I will use the missing data from you, if you have no objection..

 

I have made script that dump EEE codes for "ALL Mac Models"

 

above posted dump is 40%

 

Soon i Post for "EVERY" mac logic board

 

Even i made a script that accurately Generate MLB as you said in this post

 

 

Found Y and W calculation...(if not later) Already said

 

 

 

Like for serial number at certain point from 11 lenght that became 12 digits lenght due to the PP part that have became PPP (but also for the CCC+ part) the same for the MLB. This example regard a real serial number, so not MLB, but I'm pretty sure the logic is the same (like they are using certified standard ISO 9000 in UE for quality reason, and suppliers must comply).

 

this is a valid Sn: C02HM***DTY3, masked here,  put into Apple Service Center online:

Nice Name: MacBook Pro 13 inch Unibody Core i5 (Mid 2012)

Machine Model: MacBookPro9,2

Please visit our facebook page

Family name: A1278

Model Number: MD101

Group1: MacBook

Group2: Pro

Generation:

CPU speed: 2.5GHz

Screen size: 13 inch

Screen resolution: 1280x800 pixels

Colour: Aluminium

Production week : -18- (May)

Production year : -2012-

Model introduced: -2012-

Memory - flavour: DDR3-S-1600

Memory - number of slots: 2

Memory - maximum total: 16GB

Memory - largest module: 8GB

Factory: C0 (Quanta Computer (Susidiary = Tech Com) China)

PPP Y W SSS  CCCC

C02  H M ***  DTY3

 

let's go:

 

Y

calculated like 0 stand for 2010 (or also 2000, 2020...but DTY3 ensure is 2010+), letter to choose depend by the week (see "W") .

0    1    2    3   4    5      6     7    8     9           (last number of a year example 2012)

CD  FG HJ   KL MN PQ   RS    TV  WX  YZ         (for each year, two letters, the first in case of Mid, the second for Late)

then year is 2012, under 2 you can find HJ. because H and not J? see W table below.

 

W

a year can have 52 + 1 weeks (year depending), so max 26 for MId and 27 for Late. 

1 2 3 4 5 6 7 8 9  10  11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

1 2 3 4 5 6 7 8 9  C   D   F   G   H  J   K   L   M  N    P  Q   R  T   V   W  X  Y

 

then week is 18 so choose M  of (Mid 2012 because of table say that under 2 that stand for 2012, H is the Mid of the year)      :lol:

For example, today we are i august 13 (33° week), YW will be Q6 because we are in week 6 of Late 2015. Simply because 33 is out of 27 weeks in our W table, and we are now in the Late of the year, and the new week is the sixth of the second half-year.

 

PPP

C0 mean China, 2 is the establishment nr 2 in china (the production is increased like also the places), so is a number always?NO can be a letter too.

 

CCCC

no fancy, regard a specific model, equal for identical model: DTY3 = particular CPU, video card etc, and sure is a MacBook Pro 13 unibody 

 

SSS

a progressive number? rest this to find a table. Ok there's a X in the middle (*X*),

is not a number like max 999 MacBook Pro in a week, the number would be too low for 53 week  of production.

How many mac Apple produce in a year? It is related to the year or a week? naaah! maybe in part but quantity is important for sales invoice, but not for a serial number.

ISO spec, but also ANSI require traceability, ie when you know where and when, you need to know who!

..basically conducible to a machinery and operator!  ..it is a possibility

 

Suggestions...is right?  :D ....just test with real Mac..

 

EDIT

serial and MLB are related on how are built for location, year an week. location can be the same of the serial, but also not, the one on post #532  match, probably the motherboard is assembled in the same factory where the final Mac comes out, nothing strange.

 

 

 

My Every work is Open for Hackintosh community...

Just mention credit ... it take few letters like "Hanger1"

Share this post


Link to post
Share on other sites

I have made script that dump EEE codes for "ALL Mac Models"

 

Ok, that is what intrest me.

I have made script that dump EEE codes for "ALL Mac Models"

From the web?
I create a obj-class that create the MLB, two moth ego... but no time to finish Pandora until now..

 

Just mention credit ... it take few letters like "Hanger1"

 
I will (sure specifically for the EEE codes), than the same for any other contributors here

 

EDIT

 

Yes my week calculation is right I think (Pandora will know also if an year in particular have/had 52 or 53 weeks ;) )

Share this post


Link to post
Share on other sites

Good job,

if this is a script that generate these data, any chance to insert the related model like MacBookAirX,X istead of  "13\" MacBook Air (Mid 2012)"? or both? :drool:

Share this post


Link to post
Share on other sites

The link generate an error.. need to insert/edit something?

 

Are you using that to find info?

https://support.apple.com/kb/SP583?viewlocale=en_US&locale=en_US

changing SP583 ?

Share this post


Link to post
Share on other sites

same idea, but I don't know how "SP583" is correlated to a "MacBook Pro (13-inch, Mid 2010)"  :(...

 

EDIT

 

I think is the first time I see an "eMac", not aware of it until now.. :cold:

Share this post


Link to post
Share on other sites

Are you using that to find info?

 No

Apple Never Gives EEE codes for their Logic Boards

 

https://support.apple.com/kb/SP583?viewlocale=en_US&locale=en_US

above links open nicely with me

 

I use welovemacs.com

#======================= CREATING UI =============================================

#====================== END UI =============================




#======================================================= DELCLARING FUNCTIONS =============================================================

#--------------------------------------------------------- files_cleanup ----------------------------------------------------
files_cleanup () { 
CFILESLIST=(.array .my .kavan .product_name .CollectedDump)
n="0"
while [ $n -lt 5 ]
do
	if [ -f ${CFILESLIST[$n]} ] ; then
	rm ${CFILESLIST[$n]}
	fi
n=$[$n+1]
done
}
#------------------------------------------------------------- END -----------------------------------------------------------------

#-------------------------------------------------------- getting_title ----------------------------------------------------
getting_title () { 
echo "Getting Dump"
echo "collecting dump \n" 
}
#------------------------------------------------------------- END ----------------------------------------------------------------

startui () {
echo "Loading.............."
}

#------------------------------------------------------- cleaning string ---------------------------------------------------
cleaning_string () {
echo $(awk '/sc-tag-start/,/sc-tag-end/p' kav | sed 's/^.*contents//') >> .list_site
cat .list_site | tr "}" "\\n" | sed -e "s/.*id://;s/,name.*//" | cut -c 2- | rev | cut -c 2- | rev >> .my
cat .list_site | tr "}" "\\n" | sed -e "s/.*name://;s/{id:.*//" | cut -c 2- | rev | cut -c 2- | rev >> .product_name
rm .list_site
cat .my | sed -e 's/^/http:\/\/www.welovemacs.com\//' | sed -e 's/$/.html/' >> .kavan

}
#------------------------------------------------------------ END ------------------------------------------------------------------

#------------------------------------------------------- getting_output ----------------------------------------------------
getting_output () {
FILE14=.kavan
ARRAY14=(`awk '{print}' $FILE14`)
i="0"
my=$(cat .my | wc -l )
while [ $i -lt $my ]
do
	echo ${ARRAY14[$i]} >> .array
	curl -s -o .k$i ${ARRAY14[$i]}
	if [[ $(awk '/.*EEE Code.*:/{ print $0 }' .k$i | awk 'END{print}' | cut -d':' -f2 ) == *"</b>"* ]]
	then
	  echo "EEE Codes Not Found" >> .CollectedDump
  	else
	  echo "EEE Codes" $(awk '/.*EEE Code.*:/{ print $0 }' .k$i | awk 'END{print}' | cut -d':' -f2 ) >> .CollectedDump
	fi
	rm .k$i
i=$[$i+1]
done
}
#----------------------------------------------------------- END -------------------------------------------------------------------
endui () {
echo "Done!"
}
#-------------------------------------------------------- final_out ----------------------------------------------------------
final_out () {
paste -d'\n' .product_name .CollectedDump >> .final
awk 'NR>c{print A[NR%c]} {A[NR%c]=$0}' c=4 .final
rm .final
}
#---------------------------------------------------------- END -------------------------------------------------------------------

#============================================== END OF DELCLARATION ========================================================================

#============================================== EXECUTING =====================================================================

clear
files_cleanup
getting_title
startui
cleaning_string
getting_output
endui
final_out
files_cleanup

#================================================ EXIT ========================================================================






#echo "EEE Codes" $(awk '/EEE Codes:/{ print $0 }' 1 | awk 'END{print}' | cut -d':' -f2 )

This is the script

 

before runt it

first

curl -o kav http://www.welovemacs.com/loboformaair.html

 

http://www.welovemacs.com/loboformaair.htmlis link of MacBook Air logic board list

I give up , not much time exams are on .... I give you all , hope it help you and your tool ....

 

 

------------------------------

I made a script for week calculation... hope it help you..

########################################################################
# Extracting Values from Serial
WeekF=$(ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}' | cut -d'"' -f2 | cut -c4-5)

#######################################################################

SNUMBERA()
	{
	if [[ $WeekF = [ACFHKM]1 ]]; then
	    WeekNUM=1
	elif [[ $WeekF = [ACFHKM]2 ]]; then
		WeekNUM=2
	elif [[ $WeekF = [ACFHKM]3 ]]; then
		WeekNUM=3
	elif [[ $WeekF = [ACFHKM]4 ]]; then
		WeekNUM=4
	elif [[ $WeekF = [ACFHKM]5 ]]; then
		WeekNUM=5
	elif [[ $WeekF = [ACFHKM]6 ]]; then
		WeekNUM=6
	elif [[ $WeekF = [ACFHKM]7 ]]; then
		WeekNUM=7
	elif [[ $WeekF = [ACFHKM]8 ]]; then
		WeekNUM=8
	elif [[ $WeekF = [ACFHKM]9 ]]; then
		WeekNUM=9
	fi
	}
SNUMBERB()
	{
	if [[ $WeekF = [BDGJLN]1 ]]; then
		WeekNUM=27
	elif [[ $WeekF = [BDGJLN]2 ]]; then
		WeekNUM=28
	elif [[ $WeekF = [BDGJLN]3 ]]; then
		WeekNUM=29
	elif [[ $WeekF = [BDGJLN]4 ]]; then
		WeekNUM=30
	elif [[ $WeekF = [BDGJLN]5 ]]; then
		WeekNUM=31
	elif [[ $WeekF = [BDGJLN]6 ]]; then
		WeekNUM=32
	elif [[ $WeekF = [BDGJLN]7 ]]; then
		WeekNUM=33
	elif [[ $WeekF = [BDGJLN]8 ]]; then
		WeekNUM=34
	elif [[ $WeekF = [BDGJLN]9 ]]; then
		WeekNUM=35
	fi
	}
	
SWORDA()
	{
	if [[ $WeekF = [CFHKM]C ]]; then
		WeekNUM=10
	elif [[ $WeekF = [CFHKM]D ]]; then
		WeekNUM=11
	elif [[ $WeekF = [CFHKM]F ]]; then
		WeekNUM=12
	elif [[ $WeekF = [CFHKM]G ]]; then
		WeekNUM=13
	elif [[ $WeekF = [CFHKM]H ]]; then
		WeekNUM=14
	elif [[ $WeekF = [CFHKM]J ]]; then
		WeekNUM=15
	elif [[ $WeekF = [CFHKM]K ]]; then
		WeekNUM=16
	elif [[ $WeekF = [CFHKM]L ]]; then
		WeekNUM=17
	elif [[ $WeekF = [CFHKM]M ]]; then
		WeekNUM=18
	elif [[ $WeekF = [CFHKM]N ]]; then
		WeekNUM=19
	elif [[ $WeekF = [CFHKM]P ]]; then
		WeekNUM=20
	elif [[ $WeekF = [CFHKM]Q ]]; then
		WeekNUM=21
	elif [[ $WeekF = [CFHKM]R ]]; then
		WeekNUM=22
	elif [[ $WeekF = [CFHKM]T ]]; then
		WeekNUM=23
	elif [[ $WeekF = [CFHKM]V ]]; then
		WeekNUM=24
	elif [[ $WeekF = [CFHKM]W ]]; then
		WeekNUM=25
	elif [[ $WeekF = [CFHKM]X ]]; then
		WeekNUM=26
	elif [[ $WeekF = [CFHKM]Y ]]; then
		WeekNUM=27
	fi
	}

SWORDB()
	{
	if [[ $WeekF = [DGJLN]C ]]; then
		WeekNUM=36
	elif [[ $WeekF = [DGJLN]D ]]; then
		WeekNUM=37
	elif [[ $WeekF = [DGJLN]F ]]; then
		WeekNUM=38
	elif [[ $WeekF = [DGJLN]G ]]; then
		WeekNUM=39
	elif [[ $WeekF = [DGJLN]H ]]; then
		WeekNUM=40
	elif [[ $WeekF = [DGJLN]J ]]; then
		WeekNUM=41
	elif [[ $WeekF = [DGJLN]K ]]; then
		WeekNUM=42
	elif [[ $WeekF = [DGJLN]L ]]; then
		WeekNUM=43
	elif [[ $WeekF = [DGJLN]M ]]; then
		WeekNUM=44
	elif [[ $WeekF = [DGJLN]N ]]; then
		WeekNUM=45
	elif [[ $WeekF = [DGJLN]P ]]; then
		WeekNUM=46
	elif [[ $WeekF = [DGJLN]Q ]]; then
		WeekNUM=47
	elif [[ $WeekF = [DGJLN]R ]]; then
		WeekNUM=48
	elif [[ $WeekF = [DGJLN]T ]]; then
		WeekNUM=49
	elif [[ $WeekF = [DGJLN]V ]]; then
		WeekNUM=50
	elif [[ $WeekF = [DGJLN]W ]]; then
		WeekNUM=51
	elif [[ $WeekF = [DGJLN]X ]]; then
		WeekNUM=52
	elif [[ $WeekF = [DGJLN]Y ]]; then
		WeekNUM=53
	fi
	}


SEARCHN()
{
if [[ $WeekF = [ACFHKM][1-9] ]]; then
    #echo "'$WeekF' 1 - 9"
	SNUMBERA
	#echo $WeekNUM
elif [[ $WeekF = [PQRSTVWXYZEIOU][1-9] ]]; then
	echo "'$WeekF' NULL"
	echo "Serial is Incorrect"
	exit 1
elif [[ $WeekF = [A-Z]0 ]]; then
	echo "'$WeekF' NULL"
	echo "Serial is Incorrect"
	exit 
else
    #echo "'$WeekF' 27 - 35"
	SNUMBERB
	#echo $WeekNUM
fi
}

SEARCHW()
{
if [[ $WeekF = [CFHKM][CDFGHJKLMNPU] ]]; then
    #echo "'$WeekF' 10 - 27"
	SWORDA
	#echo $WeekNUM
elif [[ $WeekF = [ABPQRSTVWXYZEIOU]* ]]; then
	echo "'$WeekF' NULL"
	echo "Serial is Incorrect"
	exit 1
elif [[ $WeekF = [CFHKM][ABEIOSUZ] ]]; then
	echo "'$WeekF' NULL"
	echo "Serial is Incorrect"
	exit 1
elif [[ $WeekF = [DGJLN][ABEIOSUZ] ]]; then
	echo "'$WeekF' NULL"
	echo "Serial is Incorrect"
	exit 1
elif [[ $WeekF = [DGJLN][CDFGHJKLMNPQRSTVWXY] ]]; then
    #echo "'$WeekF' 36 - 53"
	SWORDB
	#echo $WeekNUM	
fi
}

if [[ $WeekF == [A-Z]*[0-9] ]] ; then
	SEARCHN
else
	SEARCHW
fi

#echo "WeekNum:"$WeekNUM
if [[ $WeekNUM -ge 26 ]] ; then
	let WeekNUM=$WeekNUM-26
fi
#echo $WeekNUM



if [[ $WeekNUM -le 9 ]] ; then
	echo $WeekNUM
elif [ "$WeekNUM" = "10" ] ; then
    MacW="C"
elif [ "$WeekNUM" = "11" ] ; then
    MacW="D"
elif [ "$WeekNUM" = "12" ] ; then
    MacW="F"
elif [ "$WeekNUM" = "13" ] ; then
    MacW="G"
elif [ "$WeekNUM" = "14" ] ; then
    MacW="H"
elif [ "$WeekNUM" = "15" ] ; then
    MacW="J"
elif [ "$WeekNUM" = "16" ] ; then
    MacW="K"
elif [ "$WeekNUM" = "17" ] ; then
    MacW="L"
elif [ "$WeekNUM" = "18" ] ; then
    MacW="M"
elif [ "$WeekNUM" = "19" ] ; then
    MacW="N"
elif [ "$WeekNUM" = "20" ] ; then
    MacW="P"
elif [ "$WeekNUM" = "21" ] ; then
    MacW="Q"
elif [ "$WeekNUM" = "22" ] ; then
    MacW="R"
elif [ "$WeekNUM" = "23" ] ; then
    MacW="T"
elif [ "$WeekNUM" = "24" ] ; then
    MacW="V"
elif [ "$WeekNUM" = "25" ] ; then
    MacW="W"
elif [ "$WeekNUM" = "26" ] ; then
    MacW="X"
elif [ "$WeekNUM" = "27" ] ; then
    MacW="Y"
fi

echo "W:"$MacW >> CLONMLB

I made a script for month calculation... hope it also help you..

# Calculates the human friendly year based off of the Manufacturing Year 
#ModelY is search last four number of serial to apple site and gat model info
ModelY=$(curl -s http://support-sp.apple.com/sp/product?cc=`ioreg -l|grep IOPlatformSerialNumber|awk '/Serial/ {print $4}'| sed -e 's|"||g'|cut -c 9-`|sed 's|.*<configCode>\(.*\)</configCode>.*|\1|' | tail -c 3 | cut -c1-1)
#echo "Manufacturing Year Number: $ModelY"

if [ "$ModelY" = "0" ] ; then
    MacY="CD"
elif [ "$ModelY" = "1" ] ; then
    MacY="FG"
elif [ "$ModelY" = "2" ] ; then
    MacY="HJ"
elif [ "$ModelY" = "3" ] ; then
    MacY="KL"
elif [ "$ModelY" = "4" ] ; then 
    MacY="MN"
elif [ "$ModelY" = "5" ] ; then
    MacY="PQ"
elif [ "$ModelY" = "6" ] ; then
    MacY="RS"
elif [ "$ModelY" = "7" ] ; then
    MacY="TV"
elif [ "$ModelY" = "8" ] ; then
    MacY="WX"
elif [ "$ModelY" = "9" ] ; then
    MacY="YZ"
fi

#echo $MacY

Mid_or_Late=$(curl -s http://support-sp.apple.com/sp/product?cc=`ioreg -l|grep IOPlatformSerialNumber|awk '/Serial/ {print $4}'| sed -e 's|"||g'|cut -c 9-`|sed 's|.*<configCode>\(.*\)</configCode>.*|\1|' | tail -c 11 | awk 'END{print $1}')

if [ "$Mid_or_Late" = "Mid" ] ; then
    MacY=$(echo $MacY | head -c 1)
elif [ "$Mid_or_Late" = "Late" ] ; then
    MacY=$(echo $MacY | tail -c 2)
else
	exit
fi

echo "Y:"$MacY >> CLONMLB

Above those works a u said.. hope it is correct...

Share this post


Link to post
Share on other sites

Hi, I managed to make Imessage and icloud to work.

1. Star iMessageDebug on real Mac hardware. I used Macbook air 2014 as I installed hackintosh on notebook.

2. Take serial number and board number. Change it a little with a know pattern to make unique.

3. Star iMessageDebug on your huckintosh and take smUUID.

4. In Clover editor fill smUUID(the one you get from imessagedebug), Serial number (the one you changed to make it unique) Board Number (the one you changed to make it unique).

5. Clear caches with this #####

6. Restart and login to imessage. 

7.????

8. Profit.

Share this post


Link to post
Share on other sites

Is MLB serial in the ioreg? All I can find is system serial. Also did I get this right, if my correctly formatted serial is ABCDEFGHIJKL, my MLB would be ABCDEXXXXXFGHIJKL?

Share this post


Link to post
Share on other sites

I wanted to report I now have iMessage working without a real MLB. I used the tool from http://www.insanelym...c-board/page-13 post #260 to generate a 13 digit MLB and I used the mac address from my Apple wifi card (from http://osxwifi.com (not sure if this is relevant?)) for the ROM. My smUUID is randomly generated with uuidgen and my serial is randomly generated by Clover Configurator. I received the customer code error and it took a one minute call to Apple and I'm sending and receiving SMS now!

 

I'll add that I tried to use the 17 digit MLB generator by the same author and that didn't work. I received an error with no customer code.

Checking in to report my iMessage is still working flawlessly.

Share this post


Link to post
Share on other sites

Hello everyone,

I read this thread entirely, and I think this is very interesting topic IMO. However, the knowledge about MLB is still incomplete, and for 17-digit MLB, the meanings of some digits are still unknown so I decided to do a little research by myself.

When I was collecting serials from various iFixit guides, I found that even other Apple parts (heatsink, HDD, AirPort card, etc.) also had their serials similar to that of MLB. So I started wondering if Apple has a standard to create their serials for parts/components from suppliers, which means that we should also look into the serials of other parts/components instead of logic board serials only.

So I collected serials of not only logic boards but also other Mac parts, and did some analyses on them. And here is my hypothesis about the pattern of these serials:

PPPYWWDNNNNEEEECC

Where:

PPP – The location of production, which is usually the same as the PPP part (first 3 digits) of system serial. The most common value for this component is C02 (Quanta Computer – China).

Y – Year of production (e.g: 0 for 2010, 1 for 2011, 2 for 2012 and so on).

WW – Week of production. This component ranges from 01 to 53, and is usually 1 – 2 weeks earlier than the week number implied in system serial.

D – Day of production. I checked the serials and found that this digit ranges from 1 to 7 (with 1 is the least popular value). So I doubt this digit tells us the day of production (with 1 for Sunday -> 7 for Saturday).

NNNN – Production Unit Number. This component’s function is similar to the Production Number component in the system serial (6th – 8th digits). The digits seem to be alphanumeric (with the exclusion of letter I and O), and the first digit of the component is usually 0 (zero).

EEEE – EEE Code, which links to the hardware specification of the board. Its function is quite similar to that of the Model ID component in system serial (last 4 digits). The EEE code can be found on many websites that sell Mac parts (e.g: macpartsonline.com).

CC – Unknown. Like many of you, I don’t really know about the meaning of the two last digits (could be a checksum or sth). But from my analysis, the first digit of the component is usually 1 or A, and the second digit is alphanumeric (excluding letter I and O).

 

Note: One thing interesting is that while I was writing this post, I looked again at the analysis report and realized that none of the serial (even system serial) contains the letter I or O. So we should exclude the two letters when generating the serial (no Base36 here).

 

I attached here the list of serials I collected, as well as their statistic reports. The serials were analyzed automatically and reports were created by a self-made program. Hope these details may help.

 

And a warning: DO NOT use those collected serials in your Hackintosh - Cloned serials will likely be banned by Apple.

Serial data + Reports.zip

Share this post


Link to post
Share on other sites

Checking in to report my iMessage is still working flawlessly.

 

Is the 13 digit MLB you made the same value as the Board Serial Number in the SMBIOS section of Clover Configurator? Imessage-debug says that my BoardSerialNumber is my 13 digit MLB, but I'm worried the different value for the one in SMBios is causing my issues. Otherwise everything is the same and it's not working for me.

 

Awesome! Sorry if this sounds dumb, but does this mean we can start creating the new 17 digit MLBs to activate iMessage instead of the older 13 digit ones?

Share this post


Link to post
Share on other sites

Is the 13 digit MLB you made the same value as the Board Serial Number in the SMBIOS section of Clover Configurator? Imessage-debug says that my BoardSerialNumber is my 13 digit MLB, but I'm worried the different value for the one in SMBios is causing my issues. Otherwise everything is the same and it's not working for me.

Awesome! Sorry if this sounds dumb, but does this mean we can start creating the new 17 digit MLBs to activate iMessage instead of the older 13 digit ones?

What I wrote above is just hypothesis, not surely 100% correct. However, Apple has relaxed the MLB verification check, so even a 'MLB' created by adding 5 random characters to the system serial may work (this information is from the topic 'How to Fix iMessage' by jaymonkey - google it yourself).

My hypothesis may only help you to generate a MLB serial that seems to conform Apple's serial format. I don't guarantee that the generated serial will work, and you may still have to call Apple support to white-list the generated MLB serial.

Share this post


Link to post
Share on other sites

I've been trying to create 12 digit MacbookPro10,2 serial. I wanted to do it myself rather than using genarators and I read everything I found, but I still don't guite understand it.

 

I created couple of MacBook Pro (Retina, 13-inch, Early 2013) serials and checked those with Apples checkcoverage site. Two of those passed and was reported as genuine serials, so I must have created those correctly, but I don't understand how it says both are Early 2013. Serials are below, I thought "K" is first half and "L" is second half on 2013 models.

 

 

C02L9XXXFFRP - Ok - Early 2013
C02K7XXXFFRP - Ok - Early 2013

Share this post


Link to post
Share on other sites

Guys,

 

This guide states "ROM part is defined in SmUUID and should be 12 chars  and match the Apple's MAC address standard, otherwise illegal"

 

 

Is this still valid ?

 

Just come across a real iMac 17,1 with 11 char ROM value %ff%ff%ff%ff%fff or is it likely that this iMac has not been setup to communicate with the internet. It's a show piece for everyone to view and play with. There was no connectivity to the internet.

 

Any feedback please

Share this post


Link to post
Share on other sites

Hello everyone,

I read this thread entirely, and I think this is very interesting topic IMO. However, the knowledge about MLB is still incomplete, and for 17-digit MLB, the meanings of some digits are still unknown so I decided to do a little research by myself.

When I was collecting serials from various iFixit guides, I found that even other Apple parts (heatsink, HDD, AirPort card, etc.) also had their serials similar to that of MLB. So I started wondering if Apple has a standard to create their serials for parts/components from suppliers, which means that we should also look into the serials of other parts/components instead of logic board serials only.

So I collected serials of not only logic boards but also other Mac parts, and did some analyses on them. And here is my hypothesis about the pattern of these serials:

PPPYWWDNNNNEEEECC

Where:

PPP – The location of production, which is usually the same as the PPP part (first 3 digits) of system serial. The most common value for this component is C02 (Quanta Computer – China).

Y – Year of production (e.g: 0 for 2010, 1 for 2011, 2 for 2012 and so on).

WW – Week of production. This component ranges from 01 to 53, and is usually 1 – 2 weeks earlier than the week number implied in system serial.

D – Day of production. I checked the serials and found that this digit ranges from 1 to 7 (with 1 is the least popular value). So I doubt this digit tells us the day of production (with 1 for Sunday -> 7 for Saturday).

NNNN – Production Unit Number. This component’s function is similar to the Production Number component in the system serial (6th – 8th digits). The digits seem to be alphanumeric (with the exclusion of letter I and O), and the first digit of the component is usually 0 (zero).

EEEE – EEE Code, which links to the hardware specification of the board. Its function is quite similar to that of the Model ID component in system serial (last 4 digits). The EEE code can be found on many websites that sell Mac parts (e.g: macpartsonline.com).

CC – Unknown. Like many of you, I don’t really know about the meaning of the two last digits (could be a checksum or sth). But from my analysis, the first digit of the component is usually 1 or A, and the second digit is alphanumeric (excluding letter I and O).

 

Note: One thing interesting is that while I was writing this post, I looked again at the analysis report and realized that none of the serial (even system serial) contains the letter I or O. So we should exclude the two letters when generating the serial (no Base36 here).

 

I attached here the list of serials I collected, as well as their statistic reports. The serials were analyzed automatically and reports were created by a self-made program. Hope these details may help.

 

And a warning: DO NOT use those collected serials in your Hackintosh - Cloned serials will likely be banned by Apple.

 

The day of week supposition looks unlikely to me after looking at "al3xtjames" MacGen scripts (https://github.com/al3xtjames/MacGen).  This repository has what appears to be an extensive catalogue of valid identifies and the MLB is documented as:

    PPP Y WW TTT CC EEEE KK

 

where:

      TTT is the board type

      CC  is hypothesized to be a checksum (but not known)

      KK is not explained in comments

 

He has a list of presumed valid values (selects one at random when generating MLB):

   for CC:  'GU' '4N' 'J9' 'QX' 'OP' 'CD' '3F' 'U5' 'KP' 'D5' 'SJ' '7P' 'RG' 'W5' '92' 'MA' '2Y' '26' 'L0' 'NA' 'TL' '2D' '8U'

   for KK: '1H' '1M' 'AD' '1F' 'A8' 'UE' 'JA' 'JC' '8C' 'CB' 'FB' 'A6' 'AL' 'AN' '16' 'A5' 'AH' 'AA' 'AD' 'AK' 'AN' '1W' 'AY' '1A'

From my catalogue of half a dozen 2011-era (A1311) boards it's quite plausible that he has the TTT board type field correctly identified.  The boards I've seen have codes of:   100, 105, 201, 401, 601 (though, as you note, all of the first digits are in the range [1,7], so maybe you're right)

Share this post


Link to post
Share on other sites

@amble, little late, but I see similar problem here with SERIAL (they talk about MLB here).

So It would be nice if someone knows why amble and my sn is not correct following the assumed format of the new 12char serial.

 

PPPYWSSSCCCC where suposedly Y=year and W=week.

 

Y=> CDFGHJKLMNPQRSTVWXYZ where P should be early 2015 and Q late 2015.

These made serials C02TM2A9GG7L, C02PK1M1GG7L both gives iMac 17,1 late 2015 on everymac and shipmunk !? Don't use these so everyone can check for themselves.

 

Sorry for the off topic.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bojarek8
      Hi! 
       
      I'm Kris!  I hope my topic is in a good section.
      I am asking you guys for help in this difficult hackintosh problem. 
      For a very long time I tried to solve it myself but I have no idea how I can solve this problem.
       
       
      Description of the problem
       
       
      My problem is that I do not have access to any apple service. I am unable to log into the App Store using my Apple ID. I am unable to log into iCloud account in system preferences. iMessage and Facetime also do not work.  Messages that I get when I try to log in: "An error occurred during activation. Try again" 
       
      in iMessage: "An error occurred during activation. Try again" 
      in App Store: "This device or computer can not be verified. Contact the support department for help"
      in Face Time: "There was an error during activation. Try again"
       
      In summary, I am unable to log in to any apple network service. 
       
      My Specification 
       
      Motherboard:  Acer MG43M
       
      Processor: Intel(R) Core(TM)2 Duo CPU  E7600  3.06GHz
       
      Graphic card: Gigabyte GeForce 9600GT 515MB 
       
      Wi-fi: TP-LINK  TL-WN881ND
       
      Ethernet: (not supported) 
       
      Audio: (rather, it is not needed here)
       
      Files: 
       
      My config.plist: https://drive.google.com/drive/folders/1vlYJC329sz6yuTwFr-k0fOs3rfhKeI6l
       
       
       
       
       



    • By xXConcasXx
      Salve,
      Possiedo un Asus N552VW UHD con le seguenti specifiche:
      Intel Core i7 6700hq con display 15 pollici in 4K
      Grafica integrata Intel HD 530
      Grafica dedicata NVIDIA GeForce GTX 960m 4GB
      Chipset Intel HM 170
      16 GB RAM DDR4 2400 MHz
      1 SSD m.2 512 GB
      1 HDD SATA 1 TB
      1 HDD SATA 1 TB (ho rimosso il masterizzatore)
      WiFi Broadcom BCM94352Z M.2 NGFF con Handoff e AirPort
      con i seguenti OS gestiti da un'unica partizione EFI:
      macOS High Sierra 
      Windows 10
      Kali Linux
      Con tanta pazienza sono riuscito a fare funzionare tutto ad eccezione del lettore SD, Thunderbolt, forse HDMI (non l'ho testato), e FaceTime con iMessage.
      Ci tengo che sia iMessage che FaceTime funzionino (ho anche chiamato l'assistenza Apple per darli il codice errore e risolvere il problema, peraltro mi hanno fatto il controllo remoto con Apple Care, e con un po di fesserie inventate e la stupidità dell'operatore non si sono accorti che non era un MacBook, tuttavia il problema non è stato risolto)...
      Stavo pensando, se installassi El Capitan in un'altra partizione con Rt Variables e SMBIOS che uso su High Sierra potrei riuscire ad abilitare FaceTime e iMessage? Da quello che so la percentuale di successo su quella versione è più alta.
      Vi pongo questa domanda perchè non sono sicuro se sia fattibile e volevo sentire qualche parere in merito.
      PS: Nel caso sia possibile tutto ciò, quante probabilità ho di riuscire a installare El Capitan con questo hardware (non mi interessa che funzioni tutto, mi basta il minimo indispensabile per avviare l'OS con internet), poi, dove potrei trovare il link di download possibilmente a una build più vecchia possibile?.
      PSS: Ho già seguito diverse volte An iDiot's Guide To iMessage senza risultato.
       
      Grazie per l'attenzione.
    • By Twml
      I have an HP Elitebook 8460P running High Sierra 10.13.1

       

      Im trying to get iMessage and Siri working.

      When i click on iMessage and try to sign in i get error: Activation Error

      When i click on Siri i instantly am greeted with: sorry, could you say that again... and siri will not let me ask it anything

       

      My mac "Serial" on coveragecheck comes up as a macbook pro.

      My Ethernet works and i have a WiFi USB

      My Mic is hearing my voice in System Preferences

      Siri is active and configured to use the correct Mic

       

       

       

       

       

      Im fairly new to getting Mac running on Intel Based PCs. 

      any help would be greatly appreciated.

       

       

    • By fusion71au
      Clover r4385 ISO compiled with GCC and minimal config.plist compatible for use in VMWare Workstation.
       
      Tested with unlocked Workstation 12.5 running OSX 10.9 -->10.13 guest in Windows X64 host.
       
      Installation
      1. Download and unzip "EFI_Clover_r4385 for VMware.zip". Mount Clover-v2.4k-4385-X64.iso by double clicking on it.
      2. Mount your VM's EFI System Partition eg in terminal
      diskutil mount disk0s1
      3. Copy EFI folder from step 1 into the EFI partition
      4. Shutdown the VM, add bios.bootDelay = "3000" to your VM's vmx file
      5. Reboot your VM, press <F2> to access the VMware Boot Manager and add CLOVERX64.efi to the boot menu.
       
      Substitute your own unique and valid MLB and ROM variables in the /EFI/CLOVER/config.plist (Rt Variables section) to activate iMessage/Facetime on your VM.
×