Skip to content

Instantly share code, notes, and snippets.

@lukaville
Created April 3, 2018 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaville/f58021aab0074bbb3a0e0177aa1790de to your computer and use it in GitHub Desktop.
Save lukaville/f58021aab0074bbb3a0e0177aa1790de to your computer and use it in GitHub Desktop.
/* This file has been generated by the Hex-Rays decompiler.
Copyright (c) 2007-2017 Hex-Rays <info@hex-rays.com>
Detected compiler: Visual C++
*/
#include <defs.h>
//-------------------------------------------------------------------------
// Function declarations
signed int sub_3130();
signed int sub_3FE8();
signed int sub_3FFA();
signed int __fastcall sub_4008(int a1);
signed int __fastcall sub_4046(_WORD *a1, int a2);
int __fastcall sub_40AA(int result);
signed int sub_40B0();
signed int __fastcall sub_40E8(int a1);
int __fastcall sub_4108(int result);
int __fastcall sub_410E(int result);
int __fastcall sub_4114(int result);
signed int sub_411A();
int __fastcall sub_4124();
int __fastcall sub_413C(int a1, int a2, int a3, int a4);
int __fastcall sub_465E(int a1);
signed int __fastcall sub_4662(int a1, _WORD *a2);
int __fastcall sub_46E6(int a1, int a2, int a3, int a4);
int sub_49D8();
int sub_4A44();
int __fastcall sub_4B98(int a1, _DWORD *a2, unsigned int a3);
int sub_4BA4();
int __fastcall sub_4BEC(int result, _DWORD *a2, unsigned int a3);
signed int sub_672C();
unsigned int __fastcall sub_6762(int a1, int a2);
int __fastcall sub_6772(int result);
unsigned int __fastcall sub_6778(int a1, int a2);
int __fastcall sub_678C(int a1);
int sub_679A();
unsigned int __fastcall sub_67A4(int a1);
unsigned int __fastcall sub_67B2(int a1);
unsigned int __fastcall sub_67C0(int a1);
unsigned int __fastcall sub_67D0(int a1);
_DWORD *__fastcall sub_67DE(_DWORD *result);
int __fastcall sub_686A(int a1, int a2);
int __fastcall sub_6880(int a1, int a2);
int __fastcall sub_6896(int a1, int a2);
int __fastcall sub_68C2(int result);
int __fastcall sub_68C8(unsigned int a1);
int __fastcall sub_6964(unsigned int *a1);
unsigned int __fastcall sub_699A(int a1);
unsigned int sub_69A4();
__int64 __fastcall sub_6A06(_DWORD *a1, unsigned int *a2, unsigned int a3);
signed int __fastcall sub_6AF2(int a1);
int __fastcall sub_6B88(int a1, int a2, int a3, int a4);
int __fastcall sub_6DA4(signed int a1, unsigned __int16 *a2);
int __fastcall sub_6DB8(int a1, signed int a2, int a3);
int __fastcall sub_6EB4(int a1, unsigned int a2, int a3, int a4, int a5);
int __fastcall sub_718C(int a1, int a2, unsigned int a3);
unsigned int __fastcall sub_71A0(_DWORD *a1, int a2, unsigned int a3);
int __fastcall sub_71C8(int a1, unsigned int a2, int a3);
signed int sub_7824();
int sub_79F4();
int sub_7A30();
int sub_7A6A();
int sub_7AC8();
int sub_7BE6();
__int16 *sub_7CF0();
int sub_7DCE();
__int64 sub_7DF0();
int __fastcall sub_7F18(int a1);
signed int __fastcall sub_7F22(char *a1);
int __fastcall sub_7F7E(int a1, int a2);
int *__fastcall sub_7FA8(int *result, unsigned __int16 *a2);
unsigned int __fastcall sub_8046(unsigned int result, int a2);
_DWORD *__fastcall sub_80B4(_DWORD *result);
unsigned int *__fastcall sub_819E(unsigned int *result, unsigned int *a2);
int *__fastcall sub_81D4(int *result, int a2);
_DWORD *__fastcall sub_8224(_DWORD *result, int a2);
int __fastcall sub_8260(int result, int a2);
int __fastcall sub_8276(int result, int a2);
int __fastcall sub_828C(int result);
int __fastcall sub_8296(int a1);
int __fastcall sub_82A0(int result);
int __fastcall sub_82AA(int a1);
int __fastcall sub_82B4(int result, int a2);
_DWORD *__fastcall sub_82CA(_DWORD *result, signed int a2, signed int a3, int a4);
unsigned int __fastcall sub_8346(int a1);
__int16 *__fastcall sub_836C(__int16 *result, int a2);
_WORD *__fastcall sub_83E6(_WORD *result, _WORD *a2);
_WORD *__fastcall sub_845E(_WORD *result, unsigned __int16 *a2);
_WORD *__fastcall sub_84CE(_WORD *result, _WORD *a2);
_WORD *__fastcall sub_853C(_WORD *result, unsigned __int16 *a2);
int __fastcall sub_85BC(int a1, unsigned __int16 *a2, int a3, int a4);
int __fastcall sub_8614(int result, _WORD *a2);
__int16 *__fastcall sub_8634(__int16 *result, int a2);
int __fastcall sub_864C(int result, __int16 a2, int a3);
__int16 *__fastcall sub_8660(__int16 *result, int a2);
int __fastcall sub_8678(int result, int a2);
int __fastcall sub_8690(int result, __int16 a2);
int __fastcall sub_869E(int result, __int16 a2);
int __fastcall sub_86AE(int result, __int16 a2);
int __fastcall sub_86BC(int result, __int16 a2);
int __fastcall sub_86CC(int result, __int16 a2);
int __fastcall sub_86D0(int result, __int16 a2);
int __fastcall sub_86E2(int result, __int16 a2);
int __fastcall sub_86F6(int result, __int16 a2);
int __fastcall sub_8708(int result, __int16 a2);
int __fastcall sub_871C(int a1);
int __fastcall sub_8720(int a1);
int __fastcall sub_8724(int a1);
int __fastcall sub_8728(int result, __int16 a2, __int16 a3, __int16 a4);
int __fastcall sub_8758(int result, __int16 a2, __int16 a3, __int16 a4);
int __fastcall sub_878C(int result, __int16 a2, __int16 a3, __int16 a4);
int __fastcall sub_87BE(int result, __int16 a2, __int16 a3, __int16 a4);
void sub_87F4();
__int16 *sub_89A6();
__int64 sub_8A26();
signed int sub_8AD0();
int __fastcall sub_8B30(int a1, int a2);
//-------------------------------------------------------------------------
// Data declarations
char aAfkpuzDddddddd[32] = "<<<<<<<<<<<<<<<AFKPUZ_ddddddddd"; // weak
_DWORD aZ[22] =
{
90,
87,
85,
82,
80,
75,
72,
60,
50,
47,
45,
42,
40,
37,
35,
32,
30,
29,
28,
27,
26,
26
}; // idb
//----- (00003130) --------------------------------------------------------
signed int sub_3130()
{
signed int result; // r0
result = 1073821704;
MEMORY[0x40013808] = 1250;
MEMORY[0x4001380C] |= 0x2004u;
MEMORY[0x40013810] |= 0x4000u;
MEMORY[0x40013818] = 0;
MEMORY[0x4001380C] |= 0xCu;
return result;
}
//----- (00003FE8) --------------------------------------------------------
signed int sub_3FE8()
{
signed int result; // r0
result = 1073881092;
MEMORY[0x40022004] = -839939669;
return result;
}
//----- (00003FFA) --------------------------------------------------------
signed int sub_3FFA()
{
signed int result; // r0
result = 1073881104;
MEMORY[0x40022010] |= 0x80u;
return result;
}
//----- (00004008) --------------------------------------------------------
signed int __fastcall sub_4008(int a1)
{
int v1; // r5
signed int result; // r0
v1 = a1;
result = sub_40E8(720896);
if ( result == 4 )
{
MEMORY[0x40022010] |= 2u;
MEMORY[0x40022014] = v1;
MEMORY[0x40022010] |= 0x40u;
result = sub_40E8(720896);
if ( result != 5 )
MEMORY[0x40022010] = MEMORY[0x40022010] & 0x1FFD;
}
return result;
}
//----- (00004046) --------------------------------------------------------
signed int __fastcall sub_4046(_WORD *a1, int a2)
{
_WORD *v2; // r6
int v3; // r4
signed int result; // r0
v2 = a1;
v3 = a2;
result = sub_40E8(0x2000);
if ( result == 4 )
{
MEMORY[0x40022010] |= 1u;
*v2 = v3;
result = sub_40E8(0x2000);
if ( result == 4 )
{
v2[1] = HIWORD(v3);
result = sub_40E8(0x2000);
if ( result != 5 )
MEMORY[0x40022010] = MEMORY[0x40022010] & 0x1FFE;
}
else if ( result != 5 )
{
MEMORY[0x40022010] = MEMORY[0x40022010] & 0x1FFE;
}
}
return result;
}
//----- (000040AA) --------------------------------------------------------
int __fastcall sub_40AA(int result)
{
MEMORY[0x4002200C] = result;
return result;
}
//----- (000040B0) --------------------------------------------------------
signed int sub_40B0()
{
signed int result; // r0
result = 4;
if ( MEMORY[0x4002200C] & 1 )
return 1;
if ( MEMORY[0x4002200C] & 4 )
return 2;
if ( MEMORY[0x4002200C] & 0x10 )
result = 3;
return result;
}
//----- (000040E8) --------------------------------------------------------
signed int __fastcall sub_40E8(int a1)
{
int v1; // r4
signed int result; // r0
v1 = a1;
result = sub_40B0();
while ( result == 1 && v1 )
{
result = sub_40B0();
--v1;
}
if ( !v1 )
result = 5;
return result;
}
//----- (00004108) --------------------------------------------------------
int __fastcall sub_4108(int result)
{
MEMORY[0x40003000] = result;
return result;
}
//----- (0000410E) --------------------------------------------------------
int __fastcall sub_410E(int result)
{
MEMORY[0x40003004] = result;
return result;
}
//----- (00004114) --------------------------------------------------------
int __fastcall sub_4114(int result)
{
MEMORY[0x40003008] = result;
return result;
}
//----- (0000411A) --------------------------------------------------------
signed int sub_411A()
{
signed int result; // r0
result = 1073754112;
MEMORY[0x40003000] = 43690;
return result;
}
//----- (00004124) --------------------------------------------------------
int __fastcall sub_4124()
{
int result; // r0
result = 1073754112;
MEMORY[0x40003000] = 52428;
return result;
}
//----- (0000413C) --------------------------------------------------------
int __fastcall sub_413C(int a1, int a2, int a3, int a4)
{
int v4; // r1
int v5; // r2
int v6; // r3
int v7; // r0
unsigned int v8; // r5
int v9; // r4
int v10; // r0
int v11; // r0
int v13; // [sp+0h] [bp-18h]
v13 = a4;
sub_4B98(536875268, (_DWORD *)0x800FC00, 0x12Eu);
MEMORY[0x20001760] = MEMORY[0x20001104];
sub_46E6(MEMORY[0x20001104], v4, v5, v6);
MEMORY[0x20001226] = 17186;
MEMORY[0x20001104] = -21555;
MEMORY[0x20001230] = -30584;
MEMORY[0x20001114] = 10000;
MEMORY[0x20001116] = 0;
MEMORY[0x20001118] = 0;
MEMORY[0x2000111A] = 8;
MEMORY[0x2000111C] = 0;
MEMORY[0x2000111E] = 60;
MEMORY[0x20001120] = 70;
MEMORY[0x20001122] = 5;
MEMORY[0x20001124] = 0;
MEMORY[0x20001126] = 480;
MEMORY[0x2000112A] = 1;
MEMORY[0x2000112C] = 0;
MEMORY[0x2000112E] = 50;
MEMORY[0x20001130] = 1;
MEMORY[0x20001132] = 0;
MEMORY[0x20001134] = 6;
MEMORY[0x20001136] = 150;
MEMORY[0x20001138] = 0;
MEMORY[0x2000113A] = -10536;
MEMORY[0x2000113C] = 1300;
MEMORY[0x2000113E] = 120;
MEMORY[0x20001140] = 4660;
MEMORY[0x20001144] = 60;
MEMORY[0x20001146] = 4;
MEMORY[0x20001148] = 30;
MEMORY[0x2000114A] = 10;
MEMORY[0x2000114C] = 2;
MEMORY[0x2000114E] = 1;
MEMORY[0x20001150] = 0;
MEMORY[0x20001152] = 0;
MEMORY[0x20001154] = 250;
MEMORY[0x20001156] = 50;
MEMORY[0x20001158] = 20;
MEMORY[0x2000115A] = 20;
MEMORY[0x2000115C] = 20;
MEMORY[0x2000115E] = 20;
MEMORY[0x20001160] = 20;
MEMORY[0x20001162] = 20;
MEMORY[0x20001164] = 20;
MEMORY[0x20001166] = 0;
MEMORY[0x20001168] = 0;
MEMORY[0x2000116A] = 20;
MEMORY[0x2000116C] = 20;
MEMORY[0x2000116E] = 40;
MEMORY[0x20001170] = 40;
MEMORY[0x20001172] = 40;
MEMORY[0x20001174] = 40;
MEMORY[0x20001176] = 0;
MEMORY[0x20001178] = 0;
MEMORY[0x2000117A] = 20;
MEMORY[0x2000117C] = 20;
MEMORY[0x2000117E] = 60;
MEMORY[0x20001180] = 60;
MEMORY[0x20001182] = 60;
MEMORY[0x20001184] = 60;
MEMORY[0x20001186] = 0;
MEMORY[0x20001188] = 0;
MEMORY[0x2000118A] = 30;
MEMORY[0x2000118C] = 30;
MEMORY[0x2000118E] = 100;
MEMORY[0x20001190] = 100;
MEMORY[0x20001192] = 100;
MEMORY[0x20001194] = 100;
MEMORY[0x20001196] = 0;
MEMORY[0x20001198] = 0;
MEMORY[0x2000121A] = 1;
MEMORY[0x2000121C] = 2;
MEMORY[0x2000121E] = 3;
MEMORY[0x20001220] = 750;
MEMORY[0x20001142] = 2;
MEMORY[0x20001110] = 20739;
MEMORY[0x20001112] = 264;
MEMORY[0x20001568] = sub_465E(134336512);
MEMORY[0x20001570] = sub_465E(134336516);
sub_4BA4();
MEMORY[0x20001720] = MEMORY[0x20001570];
if ( MEMORY[0x20001568] > 0xC80u || MEMORY[0x20001568] == -1 )
MEMORY[0x20001568] = 1725;
if ( MEMORY[0x20001570] >= 2485 || MEMORY[0x20001570] == -1 )
MEMORY[0x20001570] = 1242;
v7 = MEMORY[0x20001570] * MEMORY[0x20001136] / 150;
MEMORY[0x20001570] = v7;
MEMORY[0x20001598] = v7 >> 4;
MEMORY[0x20001574] = v7;
MEMORY[0x200019B0] = v7 / 2;
MEMORY[0x2000157C] = v7;
MEMORY[0x200018A4] = v7;
MEMORY[0x2000175C] = v7 / 12;
v8 = MEMORY[0x20001568];
MEMORY[0x2000196C] = 69 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x20001754] = 63 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x20001758] = 54 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x20001734] = 78 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x20001730] = 75 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x2000172C] = 73 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x20001728] = 71 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x20001724] = 68 * MEMORY[0x20001568] / 0x3Cu;
MEMORY[0x20001678] = 390 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x2000167C] = 368 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x20001680] = 362 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x20001684] = 354 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x20001688] = 346 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x2000168C] = 386 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x20001690] = 365 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x20001694] = 358 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x20001698] = 349 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x2000169C] = 341 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x200016A0] = 353 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x200016A4] = 335 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x200016A8] = 327 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x200016AC] = 319 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x200016B0] = 312 * MEMORY[0x20001568] / 0x12Cu;
MEMORY[0x200016B4] = v7 / 12;
MEMORY[0x200016B8] = 15 * v7 / 12;
MEMORY[0x20001738] = 4080 * MEMORY[0x20001754] / 0xC4Eu;
MEMORY[0x2000173C] = 4020 * MEMORY[0x20001754] / 0xC4Eu;
MEMORY[0x20001740] = 3960 * MEMORY[0x20001754] / 0xC4Eu;
MEMORY[0x20001744] = 3900 * MEMORY[0x20001754] / 0xC4Eu;
MEMORY[0x20001748] = 3855 * MEMORY[0x20001754] / 0xC4Eu;
MEMORY[0x2000174C] = 3795 * MEMORY[0x20001754] / 0xC4Eu;
MEMORY[0x20001750] = 3735 * MEMORY[0x20001754] / 0xC4Eu;
MEMORY[0x20000410] = 5;
v9 = sub_465E(134227968);
v10 = sub_465E(134345728);
if ( v9 != 1353339050 && v10 != 1353339050 )
MEMORY[0x200017BF] = v9 == 1437226410 && v10 == 1437226410;
else
MEMORY[0x200017BF] = 2;
MEMORY[0x20001524] = 4 * v8 / 5 + v8;
MEMORY[0x20001526] = v8 >> 1;
MEMORY[0x200019E6] = 4 * v8 / 5 + v8;
v11 = sub_465E(134336524);
MEMORY[0x20000306] = BYTE1(v11);
MEMORY[0x20000307] = v11;
MEMORY[0x20000305] = BYTE2(v11);
MEMORY[0x20000304] = HIBYTE(v11);
sub_465E(134336528);
MEMORY[0x2000041C] &= 0xFFFFFFBF;
MEMORY[0x20000304] = 5;
MEMORY[0x20000305] = 4;
MEMORY[0x20000306] = 6;
MEMORY[0x20000307] = 2;
MEMORY[0x20000308] = 3;
MEMORY[0x20000309] = 1;
return v13;
}
//----- (0000465E) --------------------------------------------------------
int __fastcall sub_465E(int a1)
{
return *(_DWORD *)a1;
}
//----- (00004662) --------------------------------------------------------
signed int __fastcall sub_4662(int a1, _WORD *a2)
{
int v2; // r4
_WORD *v3; // r5
v2 = a1;
v3 = a2;
sub_4108(21845);
sub_410E(6);
sub_4114(20000);
sub_411A();
sub_3FE8();
sub_40AA(53);
sub_4008((int)v3);
sub_411A();
sub_4046(v3, v2);
sub_411A();
return sub_3FFA();
}
//----- (000046E6) --------------------------------------------------------
int __fastcall sub_46E6(int a1, int a2, int a3, int a4)
{
int v4; // r6
unsigned int v5; // r9
int v6; // r0
int v7; // r11
int v8; // r0
int v9; // r0
int v10; // r0
int v11; // r5
int v12; // r5
int v13; // r5
int v14; // r5
int v15; // r0
int v16; // r0
int v17; // r5
int v19; // [sp+0h] [bp-28h]
v19 = a4;
sub_4108(21845);
sub_410E(6);
sub_4114(10000);
do
{
sub_411A();
v4 = MEMORY[0x20001914];
MEMORY[0x20001910] = sub_465E(MEMORY[0x20001914] + 134274048);
MEMORY[0x20001914] = v4 + 4;
}
while ( MEMORY[0x20001910] != -1 );
if ( v4 == 0 )
{
MEMORY[0x2000190C] = 1;
MEMORY[0x20001914] = 0;
}
else
{
MEMORY[0x20001914] = v4 - 4;
}
v5 = MEMORY[0x20001914];
v6 = sub_465E(4 * MEMORY[0x20001914] + 134274452);
if ( v6 == -1 )
v6 = 0;
MEMORY[0x2000180C] = v6;
if ( v5 >= 4 )
MEMORY[0x20001918] = sub_465E(4 * v5 + 134274436);
else
MEMORY[0x20001918] = 0;
if ( MEMORY[0x2000180C] >= MEMORY[0x20001918] && (unsigned int)(MEMORY[0x2000180C] - MEMORY[0x20001918]) < 0x7A121 )
{
v15 = sub_465E(4 * v5 + 134274448);
if ( v15 == -1 )
v15 = 0;
MEMORY[0x20001808] = v15;
v16 = sub_465E(4 * v5 + 134274456);
if ( v16 == -1 )
v16 = 0;
MEMORY[0x20001810] = HIBYTE(v16);
MEMORY[0x20001811] = BYTE2(v16);
MEMORY[0x20001812] = BYTE1(v16);
MEMORY[0x20001813] = v16;
v17 = sub_465E(4 * v5 + 134274460);
if ( v17 == -1 )
v17 = 0;
MEMORY[0x20001818] = BYTE2(v17);
MEMORY[0x20001816] = v17;
}
else
{
if ( v5 >= 4 )
MEMORY[0x20001914] = v5 - 4;
MEMORY[0x2000180C] = MEMORY[0x20001918];
v7 = 4 * MEMORY[0x20001914];
v8 = sub_465E(4 * MEMORY[0x20001914] + 134274448);
if ( v8 == -1 )
v8 = 0;
MEMORY[0x20001808] = v8;
v9 = sub_465E(v7 + 134274456);
if ( v9 == -1 )
v9 = 0;
MEMORY[0x20001810] = HIBYTE(v9);
MEMORY[0x20001811] = BYTE2(v9);
MEMORY[0x20001812] = BYTE1(v9);
MEMORY[0x20001813] = v9;
v10 = sub_465E(v7 + 134274460);
if ( v10 == -1 )
v10 = 0;
MEMORY[0x20001818] = BYTE2(v10);
MEMORY[0x20001816] = v10;
sub_4108(21845);
sub_410E(6);
sub_4114(10000);
sub_411A();
sub_3FE8();
sub_40AA(53);
sub_4008(134274048);
MEMORY[0x20001914] = 0;
sub_411A();
sub_4046((_WORD *)(MEMORY[0x20001914] + 134274048), MEMORY[0x20001914]);
v11 = MEMORY[0x20001808];
sub_411A();
sub_4046((_WORD *)(4 * MEMORY[0x20001914] + 134274448), v11);
v12 = MEMORY[0x2000180C];
sub_411A();
sub_4046((_WORD *)(4 * MEMORY[0x20001914] + 134274452), v12);
v13 = MEMORY[0x20001813] + (MEMORY[0x20001811] << 16) + (MEMORY[0x20001810] << 24) + (MEMORY[0x20001812] << 8);
sub_411A();
sub_4046((_WORD *)(4 * MEMORY[0x20001914] + 134274456), v13);
v14 = MEMORY[0x20001816] + (MEMORY[0x20001818] << 16);
sub_411A();
sub_4046((_WORD *)(4 * MEMORY[0x20001914] + 134274460), v14);
sub_3FFA();
MEMORY[0x2000190C] = 0;
}
if ( MEMORY[0x20001810] || MEMORY[0x20001811] || MEMORY[0x20001812] )
MEMORY[0x20001814] = 36
* MEMORY[0x20001808]
/ (MEMORY[0x20001812] + 60 * MEMORY[0x20001811] + 3600 * (unsigned int)MEMORY[0x20001810]);
return v19;
}
//----- (000049D8) --------------------------------------------------------
int sub_49D8()
{
int v0; // r6
unsigned int v1; // r1
int result; // r0
sub_4108(21845);
sub_410E(6);
sub_4114(10000);
do
{
sub_411A();
v0 = MEMORY[0x20001920];
MEMORY[0x20001928] = sub_465E(MEMORY[0x20001920] + 134279168);
v1 = v0 + 4;
MEMORY[0x20001920] = v0 + 4;
}
while ( MEMORY[0x20001928] != -1 && v1 < 0x3FB );
if ( v1 == 4 )
{
MEMORY[0x2000191C] = 1;
MEMORY[0x20001920] = 0;
}
else
{
MEMORY[0x20001920] = v0 - 4;
}
MEMORY[0x20001928] = sub_465E(MEMORY[0x20001920] + 134279168);
if ( MEMORY[0x20001928] == -1 )
MEMORY[0x20001928] = 4095;
result = MEMORY[0x20001928];
MEMORY[0x20001924] = MEMORY[0x20001928];
return result;
}
//----- (00004A44) --------------------------------------------------------
int sub_4A44()
{
int v0; // r6
int result; // r0
if ( !MEMORY[0x2000191C] )
MEMORY[0x20001920] += 4;
sub_4108(21845);
sub_410E(6);
sub_4114(10000);
sub_411A();
sub_3FE8();
sub_40AA(53);
if ( MEMORY[0x20001920] > 0x3F8u )
{
MEMORY[0x20001920] = 0;
sub_4008(134279168);
}
v0 = MEMORY[0x20001884];
sub_411A();
sub_4046((_WORD *)(MEMORY[0x20001920] + 134279168), v0);
sub_3FFA();
result = 0;
MEMORY[0x2000191C] = 0;
return result;
}
//----- (00004B98) --------------------------------------------------------
int __fastcall sub_4B98(int a1, _DWORD *a2, unsigned int a3)
{
int v3; // r4
v3 = a1;
sub_4BEC(a1, a2, a3);
return v3;
}
//----- (00004BA4) --------------------------------------------------------
int sub_4BA4()
{
int result; // r0
MEMORY[0x20001884] = sub_465E(134316032);
MEMORY[0x20001888] = sub_465E(134316036);
MEMORY[0x2000188C] = sub_465E(134316040);
MEMORY[0x20001890] = sub_465E(134316044);
result = sub_465E(134316048);
MEMORY[0x20001894] = result;
return result;
}
//----- (00004BEC) --------------------------------------------------------
int __fastcall sub_4BEC(int result, _DWORD *a2, unsigned int a3)
{
char v3; // t1
bool v4; // cf
unsigned int i; // r2
int v6; // r3
int v7; // r4
int v8; // r5
int v9; // r12
bool v10; // nf
int v11; // r3
int v12; // r12
int v13; // t1
__int16 v14; // t1
int v15; // r3
int v16; // r12
_DWORD *v17; // r0
if ( a3 )
{
if ( (_DWORD)a2 << 30 )
{
while ( 1 )
{
--a3;
v3 = *(_BYTE *)a2;
a2 = (_DWORD *)((char *)a2 + 1);
*(_BYTE *)result++ = v3;
if ( !a3 )
break;
if ( !((_DWORD)a2 << 30) )
goto LABEL_5;
}
}
else
{
LABEL_5:
if ( result << 30 )
{
v4 = a3 >= 8;
for ( i = a3 - 8; v4; result = (int)(v17 + 1) )
{
v15 = *a2;
v16 = a2[1];
a2 += 2;
v4 = i >= 8;
i -= 8;
*(_DWORD *)result = v15;
v17 = (_DWORD *)(result + 4);
*v17 = v16;
}
v10 = ((i << 29) & 0x80000000) != 0;
}
else
{
v4 = a3 >= 0x10;
for ( i = a3 - 16; v4; result += 16 )
{
v6 = *a2;
v7 = a2[1];
v8 = a2[2];
v9 = a2[3];
a2 += 4;
v4 = i >= 0x10;
i -= 16;
*(_DWORD *)result = v6;
*(_DWORD *)(result + 4) = v7;
*(_DWORD *)(result + 8) = v8;
*(_DWORD *)(result + 12) = v9;
}
v10 = ((i << 29) & 0x80000000) != 0;
if ( __CFSHL__(i, 29) )
{
v11 = *a2;
v12 = a2[1];
a2 += 2;
*(_DWORD *)result = v11;
*(_DWORD *)(result + 4) = v12;
result += 8;
}
}
if ( v10 )
{
v13 = *a2;
++a2;
*(_DWORD *)result = v13;
result += 4;
}
if ( __CFSHL__(i, 31) )
{
v14 = *(_WORD *)a2;
a2 = (_DWORD *)((char *)a2 + 2);
*(_WORD *)result = v14;
result += 2;
}
if ( ((i << 31) & 0x80000000) != 0 )
*(_BYTE *)result = *(_BYTE *)a2;
}
}
return result;
}
//----- (0000672C) --------------------------------------------------------
signed int sub_672C()
{
signed int result; // r0
result = 1073876992;
MEMORY[0x40021000] |= 1u;
MEMORY[0x40021004] &= 0xF8FF0000;
MEMORY[0x40021000] &= 0xFEF6FFFF;
MEMORY[0x40021000] &= 0xFFFBFFFF;
MEMORY[0x40021004] &= 0xFF80FFFF;
MEMORY[0x40021008] = 10420224;
MEMORY[0x4002102C] = 0;
return result;
}
//----- (00006762) --------------------------------------------------------
unsigned int __fastcall sub_6762(int a1, int a2)
{
unsigned int result; // r0
result = a1 | MEMORY[0x40021004] & 0xFFC2FFFF | a2;
MEMORY[0x40021004] = result;
return result;
}
//----- (00006772) --------------------------------------------------------
int __fastcall sub_6772(int result)
{
MEMORY[0x42420060] = result;
return result;
}
//----- (00006778) --------------------------------------------------------
unsigned int __fastcall sub_6778(int a1, int a2)
{
unsigned int result; // r0
result = a1 | MEMORY[0x4002102C] & 0xFFFEFFF0 | a2;
MEMORY[0x4002102C] = result;
return result;
}
//----- (0000678C) --------------------------------------------------------
int __fastcall sub_678C(int a1)
{
int result; // r0
result = a1 | 4 * (MEMORY[0x40021004] >> 2);
MEMORY[0x40021004] = result;
return result;
}
//----- (0000679A) --------------------------------------------------------
int sub_679A()
{
return MEMORY[0x40021004] & 0xC;
}
//----- (000067A4) --------------------------------------------------------
unsigned int __fastcall sub_67A4(int a1)
{
unsigned int result; // r0
result = a1 | MEMORY[0x40021004] & 0xFFFFFF0F;
MEMORY[0x40021004] = result;
return result;
}
//----- (000067B2) --------------------------------------------------------
unsigned int __fastcall sub_67B2(int a1)
{
unsigned int result; // r0
result = a1 | MEMORY[0x40021004] & 0xFFFFF8FF;
MEMORY[0x40021004] = result;
return result;
}
//----- (000067C0) --------------------------------------------------------
unsigned int __fastcall sub_67C0(int a1)
{
unsigned int result; // r0
result = MEMORY[0x40021004] & 0xFFFFC7FF | 8 * a1;
MEMORY[0x40021004] = result;
return result;
}
//----- (000067D0) --------------------------------------------------------
unsigned int __fastcall sub_67D0(int a1)
{
unsigned int result; // r0
result = a1 | MEMORY[0x40021004] & 0xFFFF3FFF;
MEMORY[0x40021004] = result;
return result;
}
//----- (000067DE) --------------------------------------------------------
_DWORD *__fastcall sub_67DE(_DWORD *result)
{
unsigned int v1; // r2
unsigned int v2; // r3
unsigned int v3; // r3
if ( (MEMORY[0x40021004] & 0xC) == 8 )
{
v1 = ((MEMORY[0x40021004] & 0x3C0000u) >> 18) + 2;
if ( MEMORY[0x40021004] & 0x10000 )
*result = v1 * (0x7A1200 / ((MEMORY[0x4002102C] & 0xFu) + 1));
else
*result = 4000000 * v1;
}
else
{
*result = 8000000;
}
v2 = *result >> *(_BYTE *)(((MEMORY[0x40021004] & 0xF0u) >> 4) + 0x2000046C);
result[1] = v2;
result[2] = v2 >> *(_BYTE *)(((MEMORY[0x40021004] & 0x700u) >> 8) + 0x2000046C);
v3 = result[1] >> *(_BYTE *)(((MEMORY[0x40021004] & 0x3800u) >> 11) + 0x2000046C);
result[3] = v3;
result[4] = v3 / *(unsigned __int8 *)(((MEMORY[0x40021004] & 0xC000u) >> 14) + 0x2000047C);
return result;
}
//----- (0000686A) --------------------------------------------------------
int __fastcall sub_686A(int a1, int a2)
{
int result; // r0
if ( a2 )
result = a1 | MEMORY[0x40021014];
else
result = MEMORY[0x40021014] & ~a1;
MEMORY[0x40021014] = result;
return result;
}
//----- (00006880) --------------------------------------------------------
int __fastcall sub_6880(int a1, int a2)
{
int result; // r0
if ( a2 )
result = a1 | MEMORY[0x40021018];
else
result = MEMORY[0x40021018] & ~a1;
MEMORY[0x40021018] = result;
return result;
}
//----- (00006896) --------------------------------------------------------
int __fastcall sub_6896(int a1, int a2)
{
int result; // r0
if ( a2 )
result = a1 | MEMORY[0x4002101C];
else
result = MEMORY[0x4002101C] & ~a1;
MEMORY[0x4002101C] = result;
return result;
}
//----- (000068C2) --------------------------------------------------------
int __fastcall sub_68C2(int result)
{
MEMORY[0x4242004C] = result;
return result;
}
//----- (000068C8) --------------------------------------------------------
int __fastcall sub_68C8(unsigned int a1)
{
unsigned int v1; // r1
if ( a1 >> 5 == 1 )
{
v1 = MEMORY[0x40021000];
}
else if ( a1 >> 5 == 2 )
{
v1 = MEMORY[0x40021020];
}
else
{
v1 = MEMORY[0x40021024];
}
return (v1 >> (a1 & 0x1F)) & 1;
}
//----- (00006964) --------------------------------------------------------
int __fastcall sub_6964(unsigned int *a1)
{
unsigned int v1; // r1
unsigned int v2; // r2
unsigned int v3; // r3
unsigned int v4; // r4
unsigned int v5; // r5
v1 = 4095;
v2 = 0;
v3 = 0;
v4 = 0;
do
{
v5 = *(_DWORD *)(4 * v3 + 0x20001234);
if ( v2 < v5 )
v2 = *(_DWORD *)(4 * v3 + 0x20001234);
if ( v5 < v1 )
v1 = *(_DWORD *)(4 * v3 + 0x20001234);
v4 += v5;
++v3;
}
while ( v3 < 0x4B );
*a1 = v4 / 0x4B;
return v2 - v1;
}
//----- (0000699A) --------------------------------------------------------
unsigned int __fastcall sub_699A(int a1)
{
return (unsigned int)(5000 * a1) >> 12;
}
//----- (000069A4) --------------------------------------------------------
unsigned int sub_69A4()
{
unsigned int v0; // r0
unsigned int v1; // r0
unsigned int result; // r0
v0 = MEMORY[0x2000005C];
MEMORY[0x20000050] = MEMORY[0x2000005C];
MEMORY[0x2000005C] = 0;
MEMORY[0x20000060] = 5000;
if ( v0 )
{
v1 = 0x7530 / v0;
MEMORY[0x20000054] = v1;
if ( v1 < 5 && v1 )
MEMORY[0x20000054] = 15;
if ( MEMORY[0x20000054] >= 0x6Fu )
MEMORY[0x20000054] = 110;
}
if ( (signed int)MEMORY[0x2000170C] < 3 )
{
sub_718C(536871028, 0, 4u);
MEMORY[0x20000054] = 0;
}
result = sub_71A0((_DWORD *)0x20000074, MEMORY[0x20000054], 4u);
MEMORY[0x20000054] = result;
return result;
}
//----- (00006A06) --------------------------------------------------------
__int64 __fastcall sub_6A06(_DWORD *a1, unsigned int *a2, unsigned int a3)
{
_DWORD *v3; // r4
unsigned int *v4; // r5
unsigned int v5; // r7
char v6; // r0
int v7; // r8
unsigned int v8; // r7
unsigned int v9; // r0
int v10; // r7
__int64 v12; // [sp+0h] [bp-20h]
v3 = a1;
v4 = a2;
v5 = a3;
v6 = MEMORY[0x20000000];
*(_DWORD *)(4 * MEMORY[0x20000000] + 0x20001234) = a3;
MEMORY[0x20000000] = v6 + 1;
if ( (unsigned __int8)(v6 + 1) == 75 )
MEMORY[0x20000000] = 0;
if ( (unsigned int)sub_6964((unsigned int *)&v12) < 4 )
MEMORY[0x20000058] = v12;
if ( v5 < MEMORY[0x20000058] )
v7 = 0;
else
v7 = v5 - MEMORY[0x20000058];
MEMORY[0x20000070] = sub_71A0((_DWORD *)0x20000084, v7, 0x64u);
v8 = sub_71A0((_DWORD *)0x2000023C, v7, 0x32u);
v9 = sub_71A0((_DWORD *)0x20000214, v7, 0xAu);
if ( !MEMORY[0x20000064] )
{
if ( v8 + 8 < v9 && MEMORY[0x20000001] )
MEMORY[0x20000001] = 0;
if ( v9 + 8 < v8 && !MEMORY[0x20000001] )
{
MEMORY[0x20000001] = 1;
sub_69A4();
MEMORY[0x20000064] = 20;
}
}
if ( !MEMORY[0x20000060] && MEMORY[0x20000054] )
{
MEMORY[0x20000050] = 0;
MEMORY[0x20000054] = 0;
MEMORY[0x20000001] = 1;
}
v10 = MEMORY[0x20000054];
*v4 = 628 * sub_699A(MEMORY[0x20000070]) / 0x11 * v10 / 0x1770;
if ( (signed int)MEMORY[0x2000170C] < 5 )
{
*v4 = 0;
MEMORY[0x20000054] = 0;
}
*v3 = MEMORY[0x20000054];
return v12;
}
//----- (00006AF2) --------------------------------------------------------
signed int __fastcall sub_6AF2(int a1)
{
signed int i; // r1
signed int j; // r1
signed int result; // r0
for ( i = 0; i < 120; ++i )
{
*(_DWORD *)(4 * i + 0x20000B9C) = *(unsigned __int16 *)(a1 + 50);
*(_DWORD *)(4 * i + 0x20000D7C) = *(unsigned __int16 *)(a1 + 50);
}
for ( j = 0; j < 5; ++j )
*(_DWORD *)(4 * j + 0x200018D8) = *(unsigned __int16 *)(a1 + 50);
result = 0x20000000;
MEMORY[0x20000024] = 0;
return result;
}
//----- (00006B88) --------------------------------------------------------
int __fastcall sub_6B88(int a1, int a2, int a3, int a4)
{
int v4; // r7
int v5; // r4
int v6; // r5
unsigned int v7; // r8
unsigned int v8; // r0
int v9; // r1
unsigned int v10; // r0
unsigned int v11; // r0
unsigned int v12; // r0
int v13; // r1
unsigned __int8 v14; // r0
unsigned int v15; // r1
unsigned int v16; // r2
unsigned int v17; // r9
unsigned int v18; // r8
unsigned int v19; // r3
unsigned int i; // r1
unsigned int v21; // r12
unsigned int v22; // r1
int v23; // r2
unsigned int v24; // r8
unsigned int v25; // r9
int v26; // r5
unsigned int v27; // r0
unsigned int j; // r1
unsigned int v29; // r0
unsigned int k; // r1
unsigned int v31; // r2
int v32; // r1
unsigned int v33; // r5
int v34; // r1
int v36; // [sp+0h] [bp-20h]
v36 = a4;
v4 = a1;
v5 = a2;
v6 = 0;
if ( !MEMORY[0x20000028] )
{
MEMORY[0x2000001C] = MEMORY[0x20001544];
v7 = sub_71A0((_DWORD *)0x200018D8, MEMORY[0x20001544], 5u);
MEMORY[0x2000001C] = sub_71A0((_DWORD *)0x20000B9C, MEMORY[0x2000001C], 0x78u);
if ( (unsigned int)(MEMORY[0x2000001C] - 200) >= 0xF0B )
{
MEMORY[0x2000001C] = 0;
sub_6AF2(v5);
}
v8 = *(unsigned __int16 *)(v5 + 50);
if ( v8 >= MEMORY[0x2000001C] )
MEMORY[0x2000001C] = 0;
else
MEMORY[0x2000001C] -= v8;
v9 = MEMORY[0x2000001C];
MEMORY[0x20000020] = MEMORY[0x2000001C];
v10 = *(unsigned __int16 *)(v5 + 50);
if ( v10 >= v7 )
v11 = 0;
else
v11 = 2 * ((v7 - v10) / 3);
if ( MEMORY[0x2000001C] >= v11 )
v11 = MEMORY[0x2000001C];
MEMORY[0x2000001C] = 10 * (13 * v11 / 0xA) / 0x17;
MEMORY[0x20000020] = 10 * v9 / 0x17u;
MEMORY[0x20000028] = v4;
}
if ( !MEMORY[0x2000003C] )
{
v12 = sub_71A0((_DWORD *)0x20000B7C, MEMORY[0x20001544], 4u);
v13 = MEMORY[0x20000858];
*(_DWORD *)(4 * v13 + 0x200009EC) = v12;
v14 = v13 + 1;
MEMORY[0x20000858] = v13 + 1;
v15 = MEMORY[0x20000030] / 0xAu;
if ( MEMORY[0x20000030] / 0xAu >= 0x15 )
v15 = 20;
v16 = *(_DWORD *)&aZ[4 * v15];
if ( v14 >= v16 )
MEMORY[0x20000858] = 0;
v17 = 0;
v18 = 4095;
v19 = 0;
for ( i = 0; i < v16; ++i )
{
v21 = *(_DWORD *)(4 * i + 0x200009EC);
if ( v17 < v21 )
v17 = *(_DWORD *)(4 * i + 0x200009EC);
if ( v21 < v18 )
v18 = *(_DWORD *)(4 * i + 0x200009EC);
v19 += v21;
}
v22 = v19 / v16;
v23 = *(unsigned __int16 *)(v5 + 50);
if ( v22 >= v23 + 100 || v23 - 100 >= v22 )
{
MEMORY[0x20000040] = 4095;
}
else
{
if ( v18 < v17 )
v6 = v17 - v18;
MEMORY[0x20000040] = 13 * (10 * v6 / 0x17u) / 0xA;
}
MEMORY[0x2000003C] = 10;
}
if ( !MEMORY[0x20000048] )
{
v24 = 4095;
v25 = 0;
MEMORY[0x20000048] = 15;
v26 = MEMORY[0x20000859];
++MEMORY[0x20000859];
*(_DWORD *)(4 * v26 + 0x2000085C) = sub_71A0((_DWORD *)0x20000B8C, MEMORY[0x20001544], 4u);
if ( MEMORY[0x20000859] == 100 )
MEMORY[0x20000859] = 0;
v27 = 0;
for ( j = 0; j < 0x64; ++j )
v27 += *(_DWORD *)(4 * j + 0x2000085C);
v29 = v27 / 0x64;
for ( k = 0; k < 0x64; ++k )
{
v31 = *(_DWORD *)(4 * k + 0x2000085C);
if ( v31 < v24 )
v24 = *(_DWORD *)(4 * k + 0x2000085C);
if ( v25 < v31 )
v25 = *(_DWORD *)(4 * k + 0x2000085C);
}
if ( v24 >= v25 )
v32 = v24 - v25;
else
v32 = v25 - v24;
v33 = 10 * (13 * v32 / 0xAu) / 0x17;
if ( v33 >= 0x15 )
MEMORY[0x20000038] = 3000;
if ( MEMORY[0x20000030] >= 0x65u && v33 < 0x1E )
{
v34 = *(unsigned __int16 *)(v5 + 50);
if ( v34 != v29 && v29 < v34 + 50 && v34 - 50 < v29 )
{
*(_WORD *)(v5 + 50) = v29;
MEMORY[0x20000018] |= 1u;
}
}
}
return v36;
}
//----- (00006DA4) --------------------------------------------------------
int __fastcall sub_6DA4(signed int a1, unsigned __int16 *a2)
{
if ( !a1 )
return a2[21];
if ( a1 >= 80 )
return a2[23];
return a2[22];
}
//----- (00006DB8) --------------------------------------------------------
int __fastcall sub_6DB8(int a1, signed int a2, int a3)
{
signed int v3; // r4
signed int v4; // r3
signed int i; // r6
int v6; // r0
int v7; // r2
int v8; // r1
int v9; // r1
int v10; // r1
int result; // r0
int v12; // [sp+0h] [bp-30h]
int v13; // [sp+4h] [bp-2Ch]
int v14; // [sp+8h] [bp-28h]
int v15; // [sp+Ch] [bp-24h]
int v16; // [sp+10h] [bp-20h]
int v17; // [sp+14h] [bp-1Ch]
int v18; // [sp+18h] [bp-18h]
int v19; // [sp+1Ch] [bp-14h]
v3 = 0;
v4 = 50;
if ( a2 > 300 )
a2 = 300;
for ( i = 0; i < 8; ++i )
{
if ( a1 == 1 )
*(&v12 + i) = *(unsigned __int8 *)(i + a3 + 2);
if ( a1 == 2 )
*(&v12 + i) = *(unsigned __int8 *)(i + a3 + 10);
if ( a1 == 3 )
*(&v12 + i) = *(unsigned __int8 *)(i + a3 + 18);
if ( a1 == 4 )
*(&v12 + i) = *(unsigned __int8 *)(i + a3 + 26);
if ( a1 == 5 )
*(&v12 + i) = *(unsigned __int8 *)(i + a3 + 34);
}
if ( a2 >= 50 )
{
if ( a2 >= 100 )
{
if ( a2 >= 150 )
{
if ( a2 >= 180 )
{
if ( a2 >= 200 )
{
if ( a2 >= 250 )
{
v7 = v19;
if ( a2 >= 300 )
{
v3 = 300;
v6 = v19;
}
else
{
v3 = 250;
v6 = v18;
}
}
else
{
v3 = 200;
v6 = v17;
v7 = v18;
}
}
else
{
v4 = 20;
v3 = 180;
v6 = v16;
v7 = v17;
}
}
else
{
v4 = 30;
v3 = 150;
v6 = v15;
v7 = v16;
}
}
else
{
v3 = 100;
v6 = v14;
v7 = v15;
}
}
else
{
v3 = 50;
v6 = v13;
v7 = v14;
}
}
else
{
v6 = v12;
v7 = v13;
}
v8 = a2 - v3;
if ( v6 >= v7 )
v9 = v8 * (v6 - v7);
else
v9 = v8 * (v7 - v6);
v10 = v9 / v4;
if ( v6 >= v7 )
result = v6 - v10;
else
result = v6 + v10;
return result;
}
//----- (00006EB4) --------------------------------------------------------
int __fastcall sub_6EB4(int a1, unsigned int a2, int a3, int a4, int a5)
{
int v5; // r4
unsigned int v6; // r7
int v7; // r5
unsigned int *v8; // r8
signed int v9; // r7
unsigned int v10; // r4
signed int v11; // r0
signed int v12; // r7
signed int v13; // r8
unsigned int v14; // r4
int v15; // r2
signed int v16; // r3
unsigned int v17; // r4
int v18; // r1
unsigned int v19; // r8
unsigned int v20; // r0
unsigned int v21; // r9
unsigned int v22; // r0
v5 = a1;
v6 = a2;
v7 = a3;
v8 = (unsigned int *)a4;
sub_6B88(*(unsigned __int8 *)(a3 + 48), a3, a3, a4);
MEMORY[0x20000030] = v6;
v9 = (unsigned __int16)(v6 / 0xA);
if ( !MEMORY[0x20000068] )
{
MEMORY[0x20000068] = 10;
if ( v8 )
{
if ( a5 )
sub_6A06((_DWORD *)a5, v8, MEMORY[0x20001544]);
}
}
if ( v9 >= 31 )
v9 = 30;
switch ( MEMORY[0x20000002] )
{
case 0u:
MEMORY[0x2000000C] = *(_WORD *)(v7 + 50);
MEMORY[0x20000002] = 1;
break;
case 1u:
v10 = 0;
v11 = 100;
do
{
MEMORY[0x20000028] = 3;
while ( MEMORY[0x20000028] )
;
v10 += MEMORY[0x20001544];
--v11;
}
while ( v11 );
MEMORY[0x2000000E] = v10 / 0x64;
MEMORY[0x20000028] = 1000;
v12 = 4095;
v13 = 0;
do
{
v14 = MEMORY[0x20001544];
sub_71A0((_DWORD *)0x20000B9C, MEMORY[0x20001544], 0x78u);
if ( v12 >= v14 )
v12 = (unsigned __int16)v14;
if ( v14 >= v13 )
v13 = (unsigned __int16)v14;
}
while ( MEMORY[0x20000028] );
v15 = MEMORY[0x2000000E];
v16 = *(unsigned __int16 *)(v7 + 50);
if ( v16 - 10 < MEMORY[0x2000000E] && v16 >= 200 )
{
if ( v12 >= v13 )
v17 = 0;
else
v17 = v13 - v12;
if ( v17 < 0xA )
{
*(_WORD *)(v7 + 50) = MEMORY[0x2000000E];
if ( v15 + 5 < MEMORY[0x2000000C] || MEMORY[0x2000000C] < v15 - 5 )
*(_BYTE *)(v7 + 52) = 1;
}
}
else
{
*(_WORD *)(v7 + 50) = MEMORY[0x2000000E];
*(_BYTE *)(v7 + 52) = 1;
}
++MEMORY[0x20000002];
break;
case 2u:
if ( (unsigned int)sub_6DA4(MEMORY[0x20000030], (unsigned __int16 *)v7) < MEMORY[0x2000001C]
&& MEMORY[0x20000038]
&& v5 )
{
MEMORY[0x20000002] = 4;
MEMORY[0x2000006C] = 3000;
}
else if ( !MEMORY[0x20000044] && MEMORY[0x20000018] & 1 && !MEMORY[0x2000170C] )
{
sub_49D8();
v18 = *(unsigned __int16 *)(v7 + 50);
if ( (unsigned int)(v18 + 5) < MEMORY[0x20001924] || MEMORY[0x20001924] < (unsigned int)(v18 - 5) )
*(_BYTE *)(v7 + 52) = 1;
MEMORY[0x20000018] = 2 * (MEMORY[0x20000018] >> 1);
MEMORY[0x20000044] = 60000;
}
break;
case 4u:
v19 = MEMORY[0x20000030];
v20 = sub_6DA4(MEMORY[0x20000030], (unsigned __int16 *)v7);
v21 = MEMORY[0x2000001C];
if ( v20 >= MEMORY[0x2000001C] )
{
MEMORY[0x20000024] = 0;
}
else
{
MEMORY[0x20000024] = MEMORY[0x2000001C];
MEMORY[0x2000006C] = 3000;
}
if ( v21 < sub_6DA4(v19, (unsigned __int16 *)v7) - 5 && v19 < 0x23 )
MEMORY[0x20000002] = 7;
MEMORY[0x20000004] = sub_6DB8((unsigned __int8)v5, v19, v7);
if ( MEMORY[0x20000020] < 0xFAu || MEMORY[0x20000020] < 0x15Eu && v19 < 0x64 )
{
v22 = (unsigned __int8)aAfkpuzDddddddd[v9];
if ( v22 < MEMORY[0x20000004] )
MEMORY[0x20000004] = (unsigned __int8)aAfkpuzDddddddd[v9];
}
MEMORY[0x20000008] = MEMORY[0x20000024];
MEMORY[0x20000024] = MEMORY[0x20000024] * (unsigned int)MEMORY[0x20000004] / 0x64 / 0xA;
if ( MEMORY[0x20000024] >= 0x2Eu )
MEMORY[0x20000024] = 45;
MEMORY[0x20000006] = MEMORY[0x20000024];
if ( !MEMORY[0x20000038] )
MEMORY[0x20000002] = 6;
if ( !v5 )
MEMORY[0x20000002] = 6;
MEMORY[0x20000034] = *(_DWORD *)(4 * (v9 + 31 * MEMORY[0x20000024]) + 0x8003120);
break;
case 6u:
sub_6AF2(v7);
goto LABEL_60;
case 7u:
LABEL_60:
MEMORY[0x20000034] = 0;
MEMORY[0x20000002] = 2;
break;
default:
break;
}
MEMORY[0x2000000A] = MEMORY[0x20000034];
return MEMORY[0x20000034];
}
//----- (0000718C) --------------------------------------------------------
int __fastcall sub_718C(int a1, int a2, unsigned int a3)
{
int v3; // r4
v3 = a1;
sub_71C8(a1, a3, a2);
return v3;
}
//----- (000071A0) --------------------------------------------------------
unsigned int __fastcall sub_71A0(_DWORD *a1, int a2, unsigned int a3)
{
int v3; // r3
int v4; // r4
v3 = 0;
v4 = a3 - 1;
do
{
v3 += a1[v4--];
a1[v4 + 1] = a1[v4];
}
while ( v4 );
*a1 = a2;
return (a2 + v3) / a3;
}
//----- (000071C8) --------------------------------------------------------
int __fastcall sub_71C8(int a1, unsigned int a2, int a3)
{
unsigned int v3; // r2
int result; // r0
unsigned int v5; // r3
bool v6; // cf
signed int v7; // r1
int v8; // r1
int v9; // r1
v3 = (a3 & 0xFFFF00FF | ((unsigned __int8)a3 << 8)) & 0xFFFF | ((unsigned __int16)((unsigned __int8)a3 | (unsigned __int16)((unsigned __int8)a3 << 8)) << 16);
result = a1 + a2;
v5 = result & 3;
if ( result & 3 )
{
v6 = a2 >= v5;
a2 -= v5;
if ( !v6 )
{
v9 = a2 + v5;
if ( v9 )
*(_BYTE *)(result-- - 1) = v3;
if ( __CFSHL__(v9, 31) )
*(_BYTE *)(result-- - 1) = v3;
return result;
}
if ( (unsigned __int8)result << 31 < 0 )
*(_BYTE *)(result-- - 1) = v3;
if ( __CFSHL__(v5, 31) )
{
*(_WORD *)(result - 2) = v3;
result -= 2;
}
}
do
{
v6 = a2 >= 0x10;
a2 -= 16;
if ( v6 )
{
*(_DWORD *)(result - 16) = v3;
*(_DWORD *)(result - 12) = v3;
*(_DWORD *)(result - 8) = v3;
*(_DWORD *)(result - 4) = v3;
result -= 16;
}
}
while ( a2 != 0 && v6 );
v6 = __CFSHL__(a2, 29);
v7 = a2 << 29;
if ( v6 )
{
*(_DWORD *)(result - 8) = v3;
*(_DWORD *)(result - 4) = v3;
result -= 8;
}
if ( v7 < 0 )
{
*(_DWORD *)(result - 4) = v3;
result -= 4;
}
v6 = __CFSHL__(v7, 2);
v8 = 4 * v7;
if ( v6 )
{
*(_WORD *)(result - 2) = v3;
result -= 2;
}
if ( v8 < 0 )
*(_BYTE *)(result-- - 1) = v3;
return result;
}
//----- (00007824) --------------------------------------------------------
signed int sub_7824()
{
signed int result; // r0
MEMORY[0x40012C44] &= 0x7FFFu;
MEMORY[0x40012C18] = MEMORY[0x40012C18] & 0xCFFF | 0x4000;
MEMORY[0x40012C20] &= 0xFFAFu;
MEMORY[0x40012C1C] = MEMORY[0x40012C1C] & 0xFFCF | 0x40;
MEMORY[0x40012C20] &= 0xFAFFu;
MEMORY[0x40012C18] = MEMORY[0x40012C18] & 0xFFCF | 0x40;
MEMORY[0x40012C20] &= 0xFFFAu;
MEMORY[0x40012C14] |= 0x20u;
MEMORY[0x2000192C] = 0;
++MEMORY[0x20001930];
MEMORY[0x20001934] = 0;
if ( MEMORY[0x20001930] > 0x7D0u )
{
MEMORY[0x20001930] = 2000;
if ( MEMORY[0x20000354] < 0xAu )
MEMORY[0x2000031C] = 0;
MEMORY[0x20001934] = 1;
if ( MEMORY[0x20001540] < 0xC9u )
MEMORY[0x200019D8] = 0;
else
MEMORY[0x200019D8] = (unsigned int)(752 * (MEMORY[0x20001550] + 200)) / MEMORY[0x20001540];
if ( (signed int)MEMORY[0x200019D8] > 752 )
MEMORY[0x200019D8] = 752;
}
MEMORY[0x200019C8] = MEMORY[0x200019C8] & 0xFFFFFFF9 | 2;
result = 536871808;
MEMORY[0x20000380] = 0;
return result;
}
//----- (000079F4) --------------------------------------------------------
int sub_79F4()
{
char v1; // [sp+0h] [bp-8h]
char v2; // [sp+2h] [bp-6h]
char v3; // [sp+3h] [bp-5h]
sub_7F18(1792);
v1 = 25;
v2 = 0;
v3 = 1;
sub_7F22(&v1);
v1 = 26;
v2 = 0;
v3 = 1;
sub_7F22(&v1);
return *(_DWORD *)&v1;
}
//----- (00007A30) --------------------------------------------------------
int sub_7A30()
{
sub_7A6A();
sub_67DE((_DWORD *)0x200018C4);
sub_68C2(1);
sub_67D0(0);
sub_686A(65, 1);
sub_6880(18973, 1);
return sub_6896(0x40000, 1);
}
//----- (00007A6A) --------------------------------------------------------
int sub_7A6A()
{
int v1; // [sp+0h] [bp-8h]
sub_672C();
MEMORY[0x40021000] |= 1u;
while ( !(MEMORY[0x40021000] & 2) )
;
sub_67A4(0);
sub_67C0(0);
sub_67B2(0);
sub_6778(0, 1);
sub_6762(0, 0x100000);
sub_6772(1);
while ( !sub_68C8(0x39u) )
;
sub_678C(2);
while ( sub_679A() != 8 )
;
return v1;
}
//----- (00007AC8) --------------------------------------------------------
int sub_7AC8()
{
__int16 v1; // [sp+0h] [bp-10h]
char v2; // [sp+2h] [bp-Eh]
char v3; // [sp+3h] [bp-Dh]
MEMORY[0x40021018] |= 0x20u;
sub_8046(0x300200u, 1);
sub_8046(4u, 1);
sub_8046(0x8000u, 1);
v2 = 2;
v3 = 16;
v1 = 20;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v3 = 16;
v1 = 16;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v3 = 28;
v1 = 1024;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v3 = 24;
v1 = 64;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v3 = 4;
v1 = 7;
sub_7FA8((int *)0x40010800, (unsigned __int16 *)&v1);
v1 = 2312;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v1 = -16384;
sub_7FA8((int *)0x40011000, (unsigned __int16 *)&v1);
v1 = 1;
sub_7FA8((int *)0x40011400, (unsigned __int16 *)&v1);
v3 = 24;
v1 = -8192;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v1 = 1792;
sub_7FA8((int *)0x40010800, (unsigned __int16 *)&v1);
v3 = 0;
v1 = 3;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v1 = 248;
sub_7FA8((int *)0x40010800, (unsigned __int16 *)&v1);
MEMORY[0x40010C0C] &= 0xFFFFFFEF;
return *(_DWORD *)&v1;
}
//----- (00007BE6) --------------------------------------------------------
int sub_7BE6()
{
sub_80B4((_DWORD *)0x40020008);
MEMORY[0x20001788] = 0;
MEMORY[0x2000178C] = 128;
MEMORY[0x20001790] = 256;
MEMORY[0x20001794] = 2048;
MEMORY[0x200017A0] = 0;
MEMORY[0x20001778] = 1073816652;
MEMORY[0x2000177C] = 536876344;
MEMORY[0x20001780] = 0;
MEMORY[0x20001784] = 7;
MEMORY[0x2000179C] = 0x2000;
MEMORY[0x20001798] = 32;
sub_819E((unsigned int *)0x40020008, (unsigned int *)0x20001778);
sub_81D4((int *)0x40020008, 1);
MEMORY[0x20001764] = 0;
MEMORY[0x20001768] = 1;
MEMORY[0x20001769] = 0;
MEMORY[0x2000176C] = 917504;
MEMORY[0x20001770] = 0;
MEMORY[0x20001774] = 7;
sub_8224((_DWORD *)0x40012400, 536876900);
sub_8346(1);
sub_82CA((_DWORD *)0x40012400, 6, 1, 1);
sub_82CA((_DWORD *)0x40012400, 7, 2, 1);
sub_82CA((_DWORD *)0x40012400, 5, 3, 1);
sub_82CA((_DWORD *)0x40012400, 8, 4, 1);
sub_82CA((_DWORD *)0x40012400, 3, 5, 1);
sub_82CA((_DWORD *)0x40012400, 4, 6, 1);
sub_82CA((_DWORD *)0x40012400, 9, 7, 1);
sub_8276(1073816576, 1);
sub_8260(1073816576, 1);
sub_828C(1073816576);
while ( sub_8296(1073816576) )
;
sub_82A0(1073816576);
while ( sub_82AA(1073816576) )
;
return sub_82B4(1073816576, 1);
}
//----- (00007CF0) --------------------------------------------------------
__int16 *sub_7CF0()
{
MEMORY[0x200017D8] = 0;
MEMORY[0x200017DA] = 32;
MEMORY[0x200017DC] = 752;
MEMORY[0x200017DE] = 0;
MEMORY[0x200017E0] = 1;
sub_836C((__int16 *)0x40012C00, 536877016);
sub_86CC(1073818624, 752);
MEMORY[0x200017E8] = 96;
MEMORY[0x200017EA] = 1;
MEMORY[0x200017EC] = 4;
MEMORY[0x200017EE] = 0;
MEMORY[0x200017F0] = 0;
MEMORY[0x200017F4] = 0;
sub_83E6((_WORD *)0x40012C00, (_WORD *)0x200017E8);
MEMORY[0x200017EE] = 0;
sub_845E((_WORD *)0x40012C00, (unsigned __int16 *)0x200017E8);
MEMORY[0x200017EE] = 0;
sub_84CE((_WORD *)0x40012C00, (_WORD *)0x200017E8);
MEMORY[0x200017EE] = 0;
sub_853C((_WORD *)0x40012C00, (unsigned __int16 *)0x200017E8);
sub_8690(1073818624, 8);
sub_869E(1073818624, 8);
sub_86AE(1073818624, 8);
sub_86BC(1073818624, 8);
MEMORY[0x200017F8] = 2048;
MEMORY[0x200017FA] = 1024;
MEMORY[0x200017FC] = 0;
MEMORY[0x200017FE] = 64;
MEMORY[0x20001800] = 4096;
MEMORY[0x20001802] = 0;
MEMORY[0x20001804] = 0;
sub_8614(1073818624, (_WORD *)0x200017F8);
sub_8678(1073818624, 1);
sub_864C(1073818624, 1, 1);
return sub_8634((__int16 *)0x40012C00, 1);
}
//----- (00007DCE) --------------------------------------------------------
int sub_7DCE()
{
sub_4108(21845);
sub_410E(0);
sub_4114(100);
sub_411A();
return sub_4124();
}
//----- (00007DF0) --------------------------------------------------------
__int64 sub_7DF0()
{
int v0; // r2
int v1; // r3
int v2; // r2
int v3; // r3
int v4; // r2
int v5; // r3
__int64 v7; // [sp+0h] [bp-18h]
__int16 v8; // [sp+8h] [bp-10h]
sub_6896(1, 1);
MEMORY[0x200017E7] = 4;
MEMORY[0x200017E6] = 3;
MEMORY[0x200017E4] = 7;
sub_7FA8((int *)0x40010800, (unsigned __int16 *)0x200017E4);
MEMORY[0x200017D8] = 93;
MEMORY[0x200017DA] = 0;
MEMORY[0x200017DC] = -1;
MEMORY[0x200017DE] = 0;
MEMORY[0x200017E0] = 1;
sub_836C((__int16 *)0x40000000, 536877016);
v7 = 4295098368i64;
v8 = 7;
sub_85BC(0x40000000, (unsigned __int16 *)&v7, v0, v1);
v7 = 4295098372i64;
v8 = 7;
sub_85BC(0x40000000, (unsigned __int16 *)&v7, v2, v3);
v7 = 4295098376i64;
v8 = 7;
sub_85BC(0x40000000, (unsigned __int16 *)&v7, v4, v5);
sub_86CC(0x40000000, 0);
sub_871C(0x40000000);
sub_8720(0x40000000);
sub_8724(0x40000000);
sub_8634((__int16 *)0x40000000, 1);
return v7;
}
//----- (00007F18) --------------------------------------------------------
int __fastcall sub_7F18(int a1)
{
int result; // r0
result = a1 | 0x5FA0000;
MEMORY[0xE000ED0C] = result;
return result;
}
//----- (00007F22) --------------------------------------------------------
signed int __fastcall sub_7F22(char *a1)
{
char v1; // r3
int v2; // r2
int v3; // r0
int v4; // r2
signed int result; // r0
v1 = *a1;
v2 = (unsigned __int8)*a1;
if ( a1[3] )
{
*(_BYTE *)(v2 - 536812544) = 16
* ((0xFu >> ((unsigned __int16)(1792 - (MEMORY[0xE000ED0C] & 0x700)) >> 8)) & a1[2] | (a1[1] << (4 - ((unsigned __int16)(1792 - (MEMORY[0xE000ED0C] & 0x700)) >> 8))));
v3 = (unsigned __int8)*a1;
v4 = v3 >> 5;
result = 1 << (v3 & 0x1F);
*(_DWORD *)(4 * v4 - 536813312) = result;
}
else
{
result = v2 >> 5;
*(_DWORD *)(4 * (v2 >> 5) - 536813184) = 1 << (v1 & 0x1F);
}
return result;
}
//----- (00007F7E) --------------------------------------------------------
int __fastcall sub_7F7E(int a1, int a2)
{
int result; // r0
result = a1 | a2 & 0x1FFFFF80;
MEMORY[0xE000ED08] = result;
return result;
}
//----- (00007FA8) --------------------------------------------------------
int *__fastcall sub_7FA8(int *result, unsigned __int16 *a2)
{
unsigned int v2; // r3
int v3; // r2
int v4; // r4
signed int v5; // r6
int v6; // r5
int v7; // r4
unsigned int i; // r3
signed int v9; // r6
v2 = 0;
v3 = *((_BYTE *)a2 + 3) & 0xF;
if ( *((_BYTE *)a2 + 3) & 0x10 )
v3 |= *((unsigned __int8 *)a2 + 2);
if ( (unsigned __int8)*a2 )
{
v4 = *result;
while ( v2 < 8 )
{
v5 = 1 << v2;
if ( (*a2 & (1 << v2)) == 1 << v2 )
{
v4 = v4 & ~(15 << 4 * v2) | (v3 << 4 * v2);
v6 = *((unsigned __int8 *)a2 + 3);
if ( v6 == 40 )
{
result[5] = v5;
}
else if ( v6 == 72 )
{
result[4] = v5;
}
}
++v2;
}
*result = v4;
}
if ( (signed int)*a2 > 255 )
{
v7 = result[1];
for ( i = 0; i < 8; ++i )
{
v9 = 1 << (i + 8);
if ( (*a2 & (1 << (i + 8))) == 1 << (i + 8) )
{
v7 = v7 & ~(15 << 4 * i) | (v3 << 4 * i);
if ( *((_BYTE *)a2 + 3) == 40 )
result[5] = v9;
if ( *((_BYTE *)a2 + 3) == 72 )
result[4] = v9;
}
}
result[1] = v7;
}
return result;
}
//----- (00008046) --------------------------------------------------------
unsigned int __fastcall sub_8046(unsigned int result, int a2)
{
int v2; // r4
unsigned int v3; // r4
if ( (result & 0x80000000) == 0 )
v2 = MEMORY[0x40010004];
else
v2 = MEMORY[0x4001001C];
if ( (result & 0x300000) == 3145728 )
{
v3 = v2 & 0xF0FFFFFF;
MEMORY[0x40010004] &= 0xF0FFFFFF;
}
else if ( result & 0x100000 )
{
v3 = v2 & ~(3 << (BYTE2(result) & 0xF)) | 0xF000000;
}
else
{
v3 = v2 & ~((unsigned __int16)result << 16 * (result >> 21)) | 0xF000000;
}
if ( a2 )
v3 |= (unsigned __int16)result << 16 * (result >> 21);
if ( (result & 0x80000000) == 0 )
MEMORY[0x40010004] = v3;
else
MEMORY[0x4001001C] = v3;
return result;
}
//----- (000080B4) --------------------------------------------------------
_DWORD *__fastcall sub_80B4(_DWORD *result)
{
*result = 2 * (*result >> 1);
*result = 0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
if ( result == (_DWORD *)1073872904 )
{
result = (_DWORD *)1073872900;
MEMORY[0x40020004] |= 0xFu;
}
else if ( result == (_DWORD *)1073872924 )
{
result = (_DWORD *)1073872900;
MEMORY[0x40020004] |= 0xF0u;
}
else if ( result == (_DWORD *)1073872944 )
{
result = (_DWORD *)1073872900;
MEMORY[0x40020004] |= 0xF00u;
}
else if ( result == (_DWORD *)1073872964 )
{
result = (_DWORD *)1073872900;
MEMORY[0x40020004] |= 0xF000u;
}
else if ( result == (_DWORD *)1073872984 )
{
result = (_DWORD *)1073872900;
MEMORY[0x40020004] |= 0xF0000u;
}
else if ( result == (_DWORD *)1073873004 )
{
result = (_DWORD *)1073872900;
MEMORY[0x40020004] |= 0xF00000u;
}
else if ( result == (_DWORD *)1073873024 )
{
result = (_DWORD *)1073872900;
MEMORY[0x40020004] |= 0xF000000u;
}
else if ( result == (_DWORD *)1073873928 )
{
result = (_DWORD *)1073873924;
MEMORY[0x40020404] |= 0xFu;
}
else if ( result == (_DWORD *)1073873948 )
{
result = (_DWORD *)1073873924;
MEMORY[0x40020404] |= 0xF0u;
}
else if ( result == (_DWORD *)1073873968 )
{
result = (_DWORD *)1073873924;
MEMORY[0x40020404] |= 0xF00u;
}
else if ( result == (_DWORD *)1073873988 )
{
result = (_DWORD *)1073873924;
MEMORY[0x40020404] |= 0xF000u;
}
else if ( result == (_DWORD *)1073874008 )
{
result = (_DWORD *)1073873924;
MEMORY[0x40020404] |= 0xF0000u;
}
return result;
}
//----- (0000819E) --------------------------------------------------------
unsigned int *__fastcall sub_819E(unsigned int *result, unsigned int *a2)
{
*result = *result & 0xFFFF800F | a2[2] | a2[8] | a2[4] | a2[5] | a2[6] | a2[7] | a2[9] | a2[10];
result[1] = a2[3];
result[2] = *a2;
result[3] = a2[1];
return result;
}
//----- (000081D4) --------------------------------------------------------
int *__fastcall sub_81D4(int *result, int a2)
{
bool v2; // zf
unsigned int v3; // r1
v2 = a2 == 0;
v3 = *result;
if ( v2 )
*result = 2 * (v3 >> 1);
else
*result = v3 | 1;
return result;
}
//----- (00008224) --------------------------------------------------------
_DWORD *__fastcall sub_8224(_DWORD *result, int a2)
{
result[1] = result[1] & 0xFFF0FEFF | *(_DWORD *)a2 | (*(unsigned __int8 *)(a2 + 4) << 8);
result[2] = result[2] & 0xFFF1F7FD | *(_DWORD *)(a2 + 12) | *(_DWORD *)(a2 + 8) | 2 * *(unsigned __int8 *)(a2 + 5);
result[11] = result[11] & 0xFF0FFFFF | ((unsigned __int8)(*(_BYTE *)(a2 + 16) - 1) << 20);
return result;
}
//----- (00008260) --------------------------------------------------------
int __fastcall sub_8260(int result, int a2)
{
bool v2; // zf
unsigned int v3; // r1
v2 = a2 == 0;
v3 = *(_DWORD *)(result + 8);
if ( v2 )
*(_DWORD *)(result + 8) = 2 * (v3 >> 1);
else
*(_DWORD *)(result + 8) = v3 | 1;
return result;
}
//----- (00008276) --------------------------------------------------------
int __fastcall sub_8276(int result, int a2)
{
bool v2; // zf
int v3; // r1
v2 = a2 == 0;
v3 = *(_DWORD *)(result + 8);
if ( v2 )
*(_DWORD *)(result + 8) = v3 & 0xFFFFFEFF;
else
*(_DWORD *)(result + 8) = v3 | 0x100;
return result;
}
//----- (0000828C) --------------------------------------------------------
int __fastcall sub_828C(int result)
{
*(_DWORD *)(result + 8) |= 8u;
return result;
}
//----- (00008296) --------------------------------------------------------
int __fastcall sub_8296(int a1)
{
return (*(_DWORD *)(a1 + 8) >> 3) & 1;
}
//----- (000082A0) --------------------------------------------------------
int __fastcall sub_82A0(int result)
{
*(_DWORD *)(result + 8) |= 4u;
return result;
}
//----- (000082AA) --------------------------------------------------------
int __fastcall sub_82AA(int a1)
{
return (*(_DWORD *)(a1 + 8) >> 2) & 1;
}
//----- (000082B4) --------------------------------------------------------
int __fastcall sub_82B4(int result, int a2)
{
bool v2; // zf
int v3; // r1
v2 = a2 == 0;
v3 = *(_DWORD *)(result + 8);
if ( v2 )
*(_DWORD *)(result + 8) = v3 & 0xFFAFFFFF;
else
*(_DWORD *)(result + 8) = v3 | 0x500000;
return result;
}
//----- (000082CA) --------------------------------------------------------
_DWORD *__fastcall sub_82CA(_DWORD *result, signed int a2, signed int a3, int a4)
{
if ( a2 < 10 )
result[4] = (a4 << 3 * a2) | result[4] & ~(7 << 3 * a2);
else
result[3] = (a4 << 3 * (a2 - 10)) | result[3] & ~(7 << 3 * (a2 - 10));
if ( a3 >= 7 )
{
if ( a3 >= 13 )
result[11] = (a2 << 5 * (a3 - 13)) | result[11] & ~(31 << 5 * (a3 - 13));
else
result[12] = (a2 << 5 * (a3 - 7)) | result[12] & ~(31 << 5 * (a3 - 7));
}
else
{
result[13] = (a2 << 5 * (a3 - 1)) | result[13] & ~(31 << 5 * (a3 - 1));
}
return result;
}
//----- (00008346) --------------------------------------------------------
unsigned int __fastcall sub_8346(int a1)
{
unsigned int result; // r0
if ( a1 )
{
result = MEMORY[0x40012408] | 0x800000;
MEMORY[0x40012408] |= 0x800000u;
}
else
{
result = MEMORY[0x40012408] & 0xFF7FFFFF;
MEMORY[0x40012408] &= 0xFF7FFFFF;
}
return result;
}
//----- (0000836C) --------------------------------------------------------
__int16 *__fastcall sub_836C(__int16 *result, int a2)
{
__int16 v2; // r3
v2 = *result;
if ( result == (__int16 *)1073818624
|| result == (__int16 *)1073820672
|| result == (__int16 *)0x40000000
|| result == (__int16 *)1073742848
|| result == (__int16 *)1073743872
|| result == (__int16 *)1073744896 )
{
v2 = v2 & 0xFF8F | *(_WORD *)(a2 + 2);
}
if ( result != (__int16 *)1073745920 && result != (__int16 *)1073746944 )
v2 = v2 & 0xFCFF | *(_WORD *)(a2 + 6);
*result = v2;
result[22] = *(_WORD *)(a2 + 4);
result[20] = *(_WORD *)a2;
if ( result == (__int16 *)1073818624
|| result == (__int16 *)1073820672
|| result == (__int16 *)1073823744
|| result == (__int16 *)1073824768
|| result == (__int16 *)1073825792 )
{
result[24] = *(unsigned __int8 *)(a2 + 8);
}
result[10] = 1;
return result;
}
//----- (000083E6) --------------------------------------------------------
_WORD *__fastcall sub_83E6(_WORD *result, _WORD *a2)
{
int v2; // r2
__int16 v3; // r3
int v4; // r4
result[16] &= 0xFFFEu;
LOWORD(v2) = result[2];
v3 = result[12] & 0xFF8C | *a2;
v4 = result[16] & 0xFFFD | (unsigned __int16)a2[4] | (unsigned __int16)a2[1];
if ( result == (_WORD *)1073818624
|| result == (_WORD *)1073820672
|| result == (_WORD *)1073823744
|| result == (_WORD *)1073824768
|| result == (_WORD *)1073825792 )
{
LOWORD(v4) = (v4 & 0xFFF7 | a2[5]) & 0xFFFB | a2[2];
v2 = v2 & 0xFCFF | (unsigned __int16)a2[6] | (unsigned __int16)a2[7];
}
result[2] = v2;
result[12] = v3;
result[26] = a2[3];
result[16] = v4;
return result;
}
//----- (0000845E) --------------------------------------------------------
_WORD *__fastcall sub_845E(_WORD *result, unsigned __int16 *a2)
{
int v2; // r2
int v3; // r3
int v4; // r4
result[16] &= 0xFFEFu;
LOWORD(v2) = result[2];
v3 = (unsigned __int16)(result[12] & 0x8CFF) | (*a2 << 8);
v4 = (unsigned __int16)(result[16] & 0xFFDF) | 16 * (a2[4] | a2[1]);
if ( result == (_WORD *)1073818624 || result == (_WORD *)1073820672 )
{
v4 = (v4 & 0xFF7F | 16 * a2[5]) & 0xFFBF | 16 * a2[2];
v2 = (unsigned __int16)(v2 & 0xF3FF) | 4 * (a2[6] | a2[7]);
}
result[2] = v2;
result[12] = v3;
result[28] = a2[3];
result[16] = v4;
return result;
}
//----- (000084CE) --------------------------------------------------------
_WORD *__fastcall sub_84CE(_WORD *result, _WORD *a2)
{
int v2; // r2
__int16 v3; // r3
int v4; // r4
result[16] &= 0xFEFFu;
LOWORD(v2) = result[2];
v3 = result[14] & 0xFF8C | *a2;
v4 = (unsigned __int16)(result[16] & 0xFDFF) | (((unsigned __int16)a2[4] | (unsigned __int16)a2[1]) << 8);
if ( result == (_WORD *)1073818624 || result == (_WORD *)1073820672 )
{
v4 = (v4 & 0xF7FF | ((unsigned __int16)a2[5] << 8)) & 0xFBFF | ((unsigned __int16)a2[2] << 8);
v2 = (unsigned __int16)(v2 & 0xCFFF) | 16 * ((unsigned __int16)a2[6] | (unsigned __int16)a2[7]);
}
result[2] = v2;
result[14] = v3;
result[30] = a2[3];
result[16] = v4;
return result;
}
//----- (0000853C) --------------------------------------------------------
_WORD *__fastcall sub_853C(_WORD *result, unsigned __int16 *a2)
{
int v2; // r2
int v3; // r3
int v4; // r4
result[16] &= 0xEFFFu;
LOWORD(v2) = result[2];
v3 = (unsigned __int16)(result[14] & 0x8CFF) | (*a2 << 8);
v4 = (unsigned __int16)(result[16] & 0xDFFF) | ((a2[4] | a2[1]) << 12);
if ( result == (_WORD *)1073818624 || result == (_WORD *)1073820672 )
v2 = (unsigned __int16)(v2 & 0xBFFF) | (a2[6] << 6);
result[2] = v2;
result[14] = v3;
result[32] = a2[3];
result[16] = v4;
return result;
}
//----- (000085BC) --------------------------------------------------------
int __fastcall sub_85BC(int a1, unsigned __int16 *a2, int a3, int a4)
{
int v4; // r4
unsigned __int16 *v5; // r5
__int16 v6; // r1
__int16 v7; // r2
__int16 v8; // r3
int v9; // r0
int result; // r0
v4 = a1;
v5 = a2;
v6 = a2[1];
v7 = v5[2];
v8 = v5[4];
v9 = *v5;
if ( *v5 )
{
if ( v9 == 4 )
{
sub_8758(v4, v6, v7, v8);
result = sub_86E2(v4, v5[3]);
}
else if ( v9 == 8 )
{
sub_878C(v4, v6, v7, v8);
result = sub_86F6(v4, v5[3]);
}
else
{
sub_87BE(v4, v6, v7, v8);
result = sub_8708(v4, v5[3]);
}
}
else
{
sub_8728(v4, v6, v7, v8);
result = sub_86D0(v4, v5[3]);
}
return result;
}
//----- (00008614) --------------------------------------------------------
int __fastcall sub_8614(int result, _WORD *a2)
{
*(_WORD *)(result + 68) = a2[6] | *a2 | a2[1] | a2[2] | a2[3] | a2[4] | a2[5];
return result;
}
//----- (00008634) --------------------------------------------------------
__int16 *__fastcall sub_8634(__int16 *result, int a2)
{
bool v2; // zf
__int16 v3; // r1
v2 = a2 == 0;
v3 = *result;
if ( v2 )
*result = v3 & 0xFFFE;
else
*result = v3 | 1;
return result;
}
//----- (0000864C) --------------------------------------------------------
int __fastcall sub_864C(int result, __int16 a2, int a3)
{
bool v3; // zf
__int16 v4; // r2
v3 = a3 == 0;
v4 = *(_WORD *)(result + 12);
if ( v3 )
*(_WORD *)(result + 12) = v4 & ~a2;
else
*(_WORD *)(result + 12) = a2 | v4;
return result;
}
//----- (00008660) --------------------------------------------------------
__int16 *__fastcall sub_8660(__int16 *result, int a2)
{
bool v2; // zf
__int16 v3; // r1
v2 = a2 == 0;
v3 = *result;
if ( v2 )
*result = v3 & 0xFF7F;
else
*result = v3 | 0x80;
return result;
}
//----- (00008678) --------------------------------------------------------
int __fastcall sub_8678(int result, int a2)
{
bool v2; // zf
__int16 v3; // r1
v2 = a2 == 0;
v3 = *(_WORD *)(result + 4);
if ( v2 )
*(_WORD *)(result + 4) = v3 & 0xFFFE;
else
*(_WORD *)(result + 4) = v3 | 1;
return result;
}
//----- (00008690) --------------------------------------------------------
int __fastcall sub_8690(int result, __int16 a2)
{
*(_WORD *)(result + 24) = a2 | *(_WORD *)(result + 24) & 0xFFF7;
return result;
}
//----- (0000869E) --------------------------------------------------------
int __fastcall sub_869E(int result, __int16 a2)
{
*(_WORD *)(result + 24) = *(_WORD *)(result + 24) & 0xF7FF | (a2 << 8);
return result;
}
//----- (000086AE) --------------------------------------------------------
int __fastcall sub_86AE(int result, __int16 a2)
{
*(_WORD *)(result + 28) = a2 | *(_WORD *)(result + 28) & 0xFFF7;
return result;
}
//----- (000086BC) --------------------------------------------------------
int __fastcall sub_86BC(int result, __int16 a2)
{
*(_WORD *)(result + 28) = *(_WORD *)(result + 28) & 0xF7FF | (a2 << 8);
return result;
}
//----- (000086CC) --------------------------------------------------------
int __fastcall sub_86CC(int result, __int16 a2)
{
*(_WORD *)(result + 36) = a2;
return result;
}
//----- (000086D0) --------------------------------------------------------
int __fastcall sub_86D0(int result, __int16 a2)
{
*(_WORD *)(result + 24) &= 0xFFF3u;
*(_WORD *)(result + 24) |= a2;
return result;
}
//----- (000086E2) --------------------------------------------------------
int __fastcall sub_86E2(int result, __int16 a2)
{
*(_WORD *)(result + 24) &= 0xF3FFu;
*(_WORD *)(result + 24) |= a2 << 8;
return result;
}
//----- (000086F6) --------------------------------------------------------
int __fastcall sub_86F6(int result, __int16 a2)
{
*(_WORD *)(result + 28) &= 0xFFF3u;
*(_WORD *)(result + 28) |= a2;
return result;
}
//----- (00008708) --------------------------------------------------------
int __fastcall sub_8708(int result, __int16 a2)
{
*(_WORD *)(result + 28) &= 0xF3FFu;
*(_WORD *)(result + 28) |= a2 << 8;
return result;
}
//----- (0000871C) --------------------------------------------------------
int __fastcall sub_871C(int a1)
{
return *(unsigned __int16 *)(a1 + 52);
}
//----- (00008720) --------------------------------------------------------
int __fastcall sub_8720(int a1)
{
return *(unsigned __int16 *)(a1 + 56);
}
//----- (00008724) --------------------------------------------------------
int __fastcall sub_8724(int a1)
{
return *(unsigned __int16 *)(a1 + 60);
}
//----- (00008728) --------------------------------------------------------
int __fastcall sub_8728(int result, __int16 a2, __int16 a3, __int16 a4)
{
__int16 v4; // r5
*(_WORD *)(result + 32) &= 0xFFFEu;
v4 = *(_WORD *)(result + 32);
*(_WORD *)(result + 24) = a3 | *(_WORD *)(result + 24) & 0xFF0C | 16 * a4;
*(_WORD *)(result + 32) = a2 | v4 & 0xFFFD | 1;
return result;
}
//----- (00008758) --------------------------------------------------------
int __fastcall sub_8758(int result, __int16 a2, __int16 a3, __int16 a4)
{
__int16 v4; // r5
*(_WORD *)(result + 32) &= 0xFFEFu;
v4 = *(_WORD *)(result + 32);
*(_WORD *)(result + 24) = *(_WORD *)(result + 24) & 0xCFF | (a4 << 12) | (a3 << 8);
*(_WORD *)(result + 32) = v4 & 0xFFDF | 16 * a2 | 0x10;
return result;
}
//----- (0000878C) --------------------------------------------------------
int __fastcall sub_878C(int result, __int16 a2, __int16 a3, __int16 a4)
{
__int16 v4; // r5
*(_WORD *)(result + 32) &= 0xFEFFu;
v4 = *(_WORD *)(result + 32);
*(_WORD *)(result + 28) = a3 | *(_WORD *)(result + 28) & 0xFF0C | 16 * a4;
*(_WORD *)(result + 32) = v4 & 0xFDFF | (a2 << 8) | 0x100;
return result;
}
//----- (000087BE) --------------------------------------------------------
int __fastcall sub_87BE(int result, __int16 a2, __int16 a3, __int16 a4)
{
__int16 v4; // r5
*(_WORD *)(result + 32) &= 0xEFFFu;
v4 = *(_WORD *)(result + 32);
*(_WORD *)(result + 28) = *(_WORD *)(result + 28) & 0xCFF | (a3 << 8) | (a4 << 12);
*(_WORD *)(result + 32) = v4 & 0xDFFF | (a2 << 12) | 0x1000;
return result;
}
//----- (000087F4) --------------------------------------------------------
void sub_87F4()
{
int v0; // r0
int v1; // r1
int v2; // r2
int v3; // r3
int v4; // r2
_BYTE *v5; // r3
__int16 v6; // r0
signed int i; // r1
MEMORY[0xE000E180] = -1;
MEMORY[0xE000E184] = -1;
MEMORY[0xE000E188] = -1;
sub_7F7E(0x8000000, 12288);
sub_411A();
sub_8AD0();
sub_8AD0();
sub_8AD0();
sub_7A30();
sub_8B30(1024, 1);
sub_8B30(256, 1);
MEMORY[0x2000197C] = 15238;
sub_7AC8();
sub_7DF0();
sub_7BE6();
sub_7CF0();
sub_3130();
v0 = sub_7DCE();
sub_413C(v0, v1, v2, v3);
sub_89A6();
sub_8A26();
sub_79F4();
sub_8AD0();
sub_8AD0();
sub_8AD0();
MEMORY[0x2000041C] = 0;
sub_49D8();
MEMORY[0xE000E104] = -1;
MEMORY[0xE000E108] = -1;
MEMORY[0x20001702] = MEMORY[0x20001924];
while ( !MEMORY[0x20001950] )
{
if ( MEMORY[0x20000354] < MEMORY[0x2000042C] )
MEMORY[0x2000170C] = 45900 * MEMORY[0x2000042C] / 0xEA60u;
else
MEMORY[0x2000170C] = 45900 * MEMORY[0x20000354] / 0xEA60u;
MEMORY[0x200016D0] = 0;
for ( i = 0; i < 8; ++i )
{
v4 = i + 536876752;
*(_BYTE *)(v4 + 2) = *(_WORD *)(2 * i + 0x2000115A);
v5 = (_BYTE *)(i + 536876754);
v5[8] = *(_WORD *)(2 * i + 0x2000116A);
v5[16] = *(_WORD *)(2 * i + 0x2000117A);
v6 = *(_WORD *)(2 * i + 0x2000118A);
v5[24] = v6;
*(_BYTE *)(v4 + 34) = v6;
}
MEMORY[0x20001700] = 7;
MEMORY[0x200016FA] = MEMORY[0x20001154];
MEMORY[0x200016FC] = MEMORY[0x20001156];
MEMORY[0x200016FE] = MEMORY[0x20001158];
if ( !MEMORY[0x20001A03] )
MEMORY[0x2000170E] = 2 * sub_6EB4(MEMORY[0x2000049C], MEMORY[0x2000170C], 536876752, 536876824, 536876828);
if ( MEMORY[0x20001704] )
{
MEMORY[0x20001704] = 0;
MEMORY[0x20001884] = MEMORY[0x20001702];
sub_4A44();
}
if ( (signed int)MEMORY[0x2000170E] >= 151 )
MEMORY[0x2000170E] = 150;
MEMORY[0x2000198C] = (unsigned int)MEMORY[0x2000170E] * MEMORY[0x20001570] / 0x96;
}
MEMORY[0xE000E180] = -1;
MEMORY[0xE000E184] = -1;
MEMORY[0xE000E188] = -1;
if ( (MEMORY[0x8000000] & 0x2FFE0000) == 0x20000000 )
{
sub_7824();
sub_4662(1437226410, (_WORD *)0x801F400);
sub_4662(1437226410, (_WORD *)0x8002800);
MEMORY[0x20001714] = MEMORY[0x8000004];
MEMORY[0x20001710] = MEMORY[0x8000004];
_R0 = MEMORY[0x8000000];
__asm { MSR.W MSP, R0 }
MEMORY[0x8000004](MEMORY[0x8000004]);
}
while ( 1 )
;
}
// 8000004: using guessed type int (__cdecl *)(_DWORD);
//----- (000089A6) --------------------------------------------------------
__int16 *sub_89A6()
{
__int16 v1; // [sp+0h] [bp-28h]
char v2; // [sp+2h] [bp-26h]
char v3; // [sp+3h] [bp-25h]
int v4; // [sp+4h] [bp-24h]
__int16 v5; // [sp+8h] [bp-20h]
__int16 v6; // [sp+Ah] [bp-1Eh]
__int16 v7; // [sp+10h] [bp-18h]
__int16 v8; // [sp+12h] [bp-16h]
__int16 v9; // [sp+16h] [bp-12h]
__int16 v10; // [sp+18h] [bp-10h]
sub_8046(0x1A0800u, 1);
sub_6896(2, 1);
v2 = 3;
v3 = 24;
v1 = 32;
sub_7FA8((int *)0x40010C00, (unsigned __int16 *)&v1);
v5 = 239;
v4 = 0;
v6 = 0;
sub_836C((__int16 *)0x40000400, (int)&v4);
v7 = 96;
v8 = 1;
v9 = 0;
v10 = 0;
sub_845E((_WORD *)0x40000400, (unsigned __int16 *)&v7);
sub_869E(1073742848, 8);
sub_8660((__int16 *)0x40000400, 1);
return sub_8634((__int16 *)0x40000400, 1);
}
//----- (00008A26) --------------------------------------------------------
__int64 sub_8A26()
{
__int64 v1; // [sp+0h] [bp-18h]
sub_6880(0x40000, 1);
v1 = 103074920136704i64;
sub_836C((__int16 *)0x40014800, (int)&v1);
sub_8690(1073825792, 8);
sub_864C(1073825792, 1, 1);
sub_8660((__int16 *)0x40014800, 1);
sub_8634((__int16 *)0x40014800, 1);
return v1;
}
//----- (00008AD0) --------------------------------------------------------
signed int sub_8AD0()
{
signed int i; // r4
signed int result; // r0
for ( i = 0; i < 50; ++i )
result = sub_411A();
return result;
}
//----- (00008B30) --------------------------------------------------------
int __fastcall sub_8B30(int a1, int a2)
{
int result; // r0
if ( a2 )
result = a1 | MEMORY[0xE0042004];
else
result = MEMORY[0xE0042004] & ~a1;
MEMORY[0xE0042004] = result;
return result;
}
// ALL OK, 109 function(s) have been successfully decompiled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment